From 9e60fc4d842ce0ef3531f2f8e26674a979c204ff Mon Sep 17 00:00:00 2001 From: jstilley Date: Tue, 18 Jun 2024 07:25:45 -0700 Subject: [PATCH] Adding CC to CLI for extracting inputs from DB --- armi/cli/tests/test_runEntryPoint.py | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/armi/cli/tests/test_runEntryPoint.py b/armi/cli/tests/test_runEntryPoint.py index 815d2a270..b04c04be2 100644 --- a/armi/cli/tests/test_runEntryPoint.py +++ b/armi/cli/tests/test_runEntryPoint.py @@ -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):