Skip to content

Commit

Permalink
Adding a second version of test_exposeInterfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Dec 6, 2023
1 parent be7ca5e commit f1f7ec1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 0 additions & 2 deletions armi/reactor/tests/test_reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ def loadTestReactor(
o : Operator
r : Reactor
"""
# TODO: it would be nice to have this be more stream-oriented. Juggling files is
# devilishly difficult.
global TEST_REACTOR
fName = os.path.join(inputFilePath, inputFileName)
customSettings = customSettings or {}
Expand Down
44 changes: 43 additions & 1 deletion armi/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

import yamlize

from armi import getPluginManagerOrFail
from armi import interfaces
from armi import plugins
from armi import settings
from armi.physics.neutronics import NeutronicsPlugin
from armi.reactor.blocks import Block
from armi.reactor.tests.test_reactors import loadTestReactor, TEST_ROOT


class TestPluginBasics(unittest.TestCase):
Expand Down Expand Up @@ -54,7 +56,7 @@ def test_exposeInterfaces(self):
"""Make sure that the exposeInterfaces hook is properly implemented.
.. test:: Plugins can add interfaces to the interface stack.
:id: T_ARMI_PLUGIN_INTERFACES
:id: T_ARMI_PLUGIN_INTERFACES0
:tests: R_ARMI_PLUGIN_INTERFACES
"""
plugin = NeutronicsPlugin()
Expand All @@ -76,6 +78,46 @@ def test_exposeInterfaces(self):
self.assertTrue(issubclass(interface, interfaces.Interface))
self.assertIsInstance(kwargs, dict)

def test_pluginsExposeInterfaces(self):
"""Make sure that plugins properly expose their interfaces, by checking some
known examples.
.. test:: Check that some known plugins correctly add interfaces to the stack.
:id: T_ARMI_PLUGIN_INTERFACES1
:tests: R_ARMI_PLUGIN_INTERFACES
"""
# generate a test operator, with a full set of interfaces from plugsin
o = loadTestReactor(TEST_ROOT)[0]
pm = getPluginManagerOrFail()

# test the plugins were generated
plugins = pm.get_plugins()
self.assertGreater(len(plugins), 0)

# test interfaces were generated from those plugins
ints = o.interfaces
self.assertGreater(len(ints), 0)

# test that certain plugins exist and correctly registered their interfaces
pluginStrings = " ".join([str(p) for p in plugins])
interfaceStrings = " ".join([str(i) for i in ints])

# Test that the BookkeepingPlugin registered the DatabaseInterface
self.assertIn("BookkeepingPlugin", pluginStrings)
self.assertIn("DatabaseInterface", interfaceStrings)

# Test that the BookkeepingPlugin registered the history interface
self.assertIn("BookkeepingPlugin", pluginStrings)
self.assertIn("history", interfaceStrings)

# Test that the EntryPointsPlugin registered the main interface
self.assertIn("EntryPointsPlugin", pluginStrings)
self.assertIn("main", interfaceStrings)

# Test that the FuelHandlerPlugin registered the fuelHandler interface
self.assertIn("FuelHandlerPlugin", pluginStrings)
self.assertIn("fuelHandler", interfaceStrings)


class TestPlugin(unittest.TestCase):
"""This contains some sanity tests that can be used by implementing plugins."""
Expand Down

0 comments on commit f1f7ec1

Please sign in to comment.