From fc4e1948a2688c2cc98263ed1a25fd57454da452 Mon Sep 17 00:00:00 2001 From: jstilley Date: Thu, 30 Nov 2023 16:05:11 -0800 Subject: [PATCH] Adding test crumbs --- armi/nuclearDataIO/cccc/tests/test_isotxs.py | 31 ++++++++++++++++++++ armi/nuclearDataIO/cccc/tests/test_pmatrx.py | 7 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/armi/nuclearDataIO/cccc/tests/test_isotxs.py b/armi/nuclearDataIO/cccc/tests/test_isotxs.py index f4bb35db5..6a8392ad9 100644 --- a/armi/nuclearDataIO/cccc/tests/test_isotxs.py +++ b/armi/nuclearDataIO/cccc/tests/test_isotxs.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Tests the workings of the library wrappers.""" +import filecmp import unittest from armi import nuclearDataIO @@ -19,6 +20,7 @@ from armi.nuclearDataIO import xsLibraries from armi.nuclearDataIO.cccc import isotxs from armi.tests import ISOAA_PATH +from armi.utils.directoryChangers import TemporaryDirectoryChanger class TestIsotxs(unittest.TestCase): @@ -30,6 +32,29 @@ def setUpClass(cls): # be a small library with LFPs, Actinides, structure, and coolant cls.lib = isotxs.readBinary(ISOAA_PATH) + def test_writeBinary(self): + """Test that when you write a binary ISOTXS file. + + .. test:: Write ISOTSX binary files. + :id: T_ARMI_NUCDATA_ISOTXSo + :tests: R_ARMI_NUCDATA_ISOTXS + """ + with TemporaryDirectoryChanger(): + origLib = isotxs.readBinary(ISOAA_PATH) + + fname = self._testMethodName + "temp-aa.isotxs" + isotxs.writeBinary(origLib, fname) + lib = isotxs.readBinary(fname) + + # validate the written file is still valid + nucs = lib.nuclides + self.assertTrue(nucs) + self.assertIn("AA", lib.xsIDs) + nuc = lib["U235AA"] + self.assertIsNotNone(nuc) + with self.assertRaises(KeyError): + lib.getNuclide("nonexistent", "zz") + def test_isotxsGeneralData(self): nucs = self.lib.nuclides self.assertTrue(nucs) @@ -164,6 +189,12 @@ def test_getGAMISOFileName(self): class Isotxs_merge_Tests(unittest.TestCase): def test_mergeMccV2FilesRemovesTheFileWideChi(self): + """Test merging ISOTXS files. + + .. test:: Read ISOTXS files. + :id: T_ARMI_NUCDATA_ISOTXS1 + :tests: R_ARMI_NUCDATA_ISOTXS + """ isoaa = isotxs.readBinary(ISOAA_PATH) self.assertAlmostEqual(1.0, sum(isoaa.isotxsMetadata["chi"]), 5) self.assertAlmostEqual(1, isoaa.isotxsMetadata["fileWideChiFlag"]) diff --git a/armi/nuclearDataIO/cccc/tests/test_pmatrx.py b/armi/nuclearDataIO/cccc/tests/test_pmatrx.py index 4d8e90e3f..75b33f70a 100644 --- a/armi/nuclearDataIO/cccc/tests/test_pmatrx.py +++ b/armi/nuclearDataIO/cccc/tests/test_pmatrx.py @@ -201,7 +201,12 @@ class TestProductionMatrix_FromWritten(TestPmatrx): """ def test_writtenIsIdenticalToOriginal(self): - """Make sure our writer produces something identical to the original.""" + """Make sure our writer produces something identical to the original. + + .. test:: Test reading and writing PMATRIX files. + :id: T_ARMI_NUCDATA_PMATRX + :tests: R_ARMI_NUCDATA_PMATRX + """ origLib = pmatrx.readBinary(test_xsLibraries.PMATRX_AA) fname = self._testMethodName + "temp-aa.pmatrx"