Skip to content

Commit

Permalink
Regression test for #417 (#421)
Browse files Browse the repository at this point in the history
* Add failing test

* STY: Fix line spacing issues

Co-authored-by: Poruri Sai Rahul <[email protected]>
  • Loading branch information
mdickinson and Poruri Sai Rahul authored Jun 14, 2021
1 parent 594118a commit ea03dee
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions envisage/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,53 @@ class PluginC(Plugin):
x = List(Int, [98, 99, 100], contributes_to="a.x")


# PluginD and PluginE each contribute to the other's extension points, but both
# expect to be started before contributions are made.
# xref: enthought/envisage#417


class PluginD(Plugin):
""" Plugin that expects to be started before contributing to
extension points. """

id = "D"
x = ExtensionPoint(List, id="d.x")

y = List(Int, contributes_to="e.x")

started = Bool(False)

def start(self):
self.started = True

def _y_default(self):
if self.started:
return [4, 5, 6]
else:
return []


class PluginE(Plugin):
""" Another plugin that expects to be started before contributing to
extension points. """

id = "E"
x = ExtensionPoint(List, id="e.x")

y = List(Int, contributes_to="d.x")

started = Bool(False)

def start(self):
self.started = True

def _y_default(self):
if self.started:
return [1, 2, 3]
else:
return []


class ApplicationTestCase(unittest.TestCase):
""" Tests for applications and plugins. """

Expand Down Expand Up @@ -265,6 +312,27 @@ def test_extension_point(self):
self.assertEqual(6, len(extensions))
self.assertEqual([1, 2, 3, 98, 99, 100], extensions)

def test_extension_point_resolution_occurs_after_plugin_start(self):
# Regression test for enthought/envisage#417

# Given
d = PluginD()
e = PluginE()
application = TestApplication(plugins=[d, e])

# When
application.start()

# Then
self.assertEqual(
application.get_extensions("d.x"),
[1, 2, 3],
)
self.assertEqual(
application.get_extensions("e.x"),
[4, 5, 6],
)

def test_add_extension_point_listener(self):
""" add extension point listener """

Expand Down

0 comments on commit ea03dee

Please sign in to comment.