Skip to content

Commit

Permalink
Adding test crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Dec 1, 2023
1 parent 504f9e8 commit fc4e194
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
31 changes: 31 additions & 0 deletions armi/nuclearDataIO/cccc/tests/test_isotxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# 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
from armi.nucDirectory import nuclideBases
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):
Expand All @@ -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)
Expand Down Expand Up @@ -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"])
Expand Down
7 changes: 6 additions & 1 deletion armi/nuclearDataIO/cccc/tests/test_pmatrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fc4e194

Please sign in to comment.