Skip to content

Commit

Permalink
Add add/select tests without row/col on figure not created with make_…
Browse files Browse the repository at this point in the history
…subplots
  • Loading branch information
jonmmease committed Oct 15, 2019
1 parent 40ea7fe commit 52ae979
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ def assert_update(
# Check object unchanged
self.assertEqual(obj, obj_orig)

def test_add_annotation_no_grid(self):
# Paper annotation
fig = go.Figure()
fig.add_annotation(text="A")
annot = fig.layout.annotations[-1]
self.assertEqual(annot.text, "A")
self.assertEqual(annot.xref, "paper")
self.assertEqual(annot.yref, "paper")

# Not valid to add annotation by row/col
with self.assertRaisesRegexp(Exception, "make_subplots"):
fig.add_annotation(text="B", row=1, col=1)

def test_add_annotations(self):
# Paper annotation
self.fig.add_annotation(text="A")
Expand Down Expand Up @@ -111,6 +124,16 @@ def test_add_annotations(self):
with self.assertRaisesRegexp(ValueError, "of type polar"):
self.fig.add_annotation(text="D", row=2, col=2)

def test_select_annotations_no_grid(self):
(
self.fig.add_annotation(text="A1", arrowcolor="red")
.add_annotation(text="A2", arrowcolor="blue")
.add_annotation(text="A3", arrowcolor="blue")
)
self.assert_selected("annotations", [0, 1, 2])
self.assert_selected("annotations", [0], selector=dict(arrowcolor="red"))
self.assert_selected("annotations", [1, 2], selector=dict(arrowcolor="blue"))

def test_select_annotations(self):
(
self.fig.add_annotation(text="A1", arrowcolor="red")
Expand Down

0 comments on commit 52ae979

Please sign in to comment.