Skip to content

Commit

Permalink
Adding CC to CLI for extracting inputs from DB
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Jun 18, 2024
1 parent 0dfa8d2 commit 9e60fc4
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions armi/cli/tests/test_runEntryPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,32 @@ def test_expandBlueprintsBasics(self):

class TestExtractInputs(unittest.TestCase):
def test_extractInputsBasics(self):
ei = ExtractInputs()
ei.addOptions()
ei.parse_args(["/path/to/fake"])
with TemporaryDirectoryChanger() as newDir:
# build test DB
o, r = loadTestReactor(TEST_ROOT)
dbi = DatabaseInterface(r, o.cs)
dbPath = os.path.join(newDir.destination, f"{self._testMethodName}.h5")
dbi.initDB(fName=dbPath)
db = dbi.database
db.writeToDB(r)

self.assertEqual(ei.name, "extract-inputs")
self.assertEqual(ei.args.output_base, "/path/to/fake")
# init the CLI
ei = ExtractInputs()
ei.addOptions()
ei.parse_args([dbPath])

with self.assertRaises(FileNotFoundError):
# The "fake" file doesn't exist, so this should fail.
ei.invoke()
# test the CLI initialization
self.assertEqual(ei.name, "extract-inputs")
self.assertEqual(ei.args.output_base, dbPath[:-3])

# run the CLI on a test DB, verify it worked via logging
with mockRunLogs.BufferLog() as mock:
runLog.LOG.startLog("test_extractInputsBasics")
runLog.LOG.setVerbosity(logging.INFO)
self.assertEqual("", mock.getStdout())
ei.invoke()
self.assertIn("Writing settings to", mock.getStdout())
self.assertIn("Writing blueprints to", mock.getStdout())


class TestInjectInputs(unittest.TestCase):
Expand Down

0 comments on commit 9e60fc4

Please sign in to comment.