Skip to content

Commit

Permalink
Adding code coverage to snapshots and massFracs (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Feb 6, 2023
1 parent 3b199b6 commit 5d8d7c6
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 9 deletions.
1 change: 0 additions & 1 deletion armi/nuclearDataIO/cccc/tests/test_dlayxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# pylint: disable=missing-function-docstring,missing-class-docstring,protected-access,invalid-name,no-self-use,no-method-argument,import-outside-toplevel
import copy
import filecmp
import os
import unittest

import numpy
Expand Down
1 change: 0 additions & 1 deletion armi/nuclearDataIO/cccc/tests/test_pmatrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""
# pylint: disable=missing-function-docstring,missing-class-docstring,protected-access,invalid-name,no-self-use,no-method-argument,import-outside-toplevel
import filecmp
import os
import unittest

from armi import nuclearDataIO
Expand Down
12 changes: 11 additions & 1 deletion armi/operators/tests/test_operatorSnapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
# pylint: disable=missing-function-docstring,missing-class-docstring,protected-access,invalid-name,no-method-argument,import-outside-toplevel
import unittest

from armi import settings
from armi.bookkeeping.db.databaseInterface import DatabaseInterface
from armi.operators import getOperatorClassFromSettings
from armi.operators.runTypes import RunTypes
from armi.operators.snapshots import OperatorSnapshots
from armi.reactor.tests import test_reactors
from armi.settings.fwSettings.databaseSettings import CONF_FORCE_DB_PARAMS
from armi.operators.runTypes import RunTypes


class TestOperatorSnapshots(unittest.TestCase):
Expand Down Expand Up @@ -62,5 +64,13 @@ def test_mainOperate(self):
self.assertEqual(self.r.core.p.power, 100000000.0)


class TestOperatorSnapshotsSettings(unittest.TestCase):
def test_getOperatorClassFromSettings(self):
cs = settings.Settings()
cs = cs.modified(newSettings={"runType": RunTypes.SNAPSHOTS})
clazz = getOperatorClassFromSettings(cs)
self.assertEqual(clazz, OperatorSnapshots)


if __name__ == "__main__":
unittest.main()
3 changes: 1 addition & 2 deletions armi/physics/neutronics/tests/test_neutronicsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"""unit tests for the neutronics plugin"""
# pylint: disable=missing-function-docstring,missing-class-docstring,protected-access,invalid-name,no-self-use,no-method-argument,import-outside-toplevel
import io
import os
import unittest

from ruamel.yaml import YAML

from armi import getPluginManagerOrFail, settings, tests
from armi.operators import settingsValidation
from armi.physics import neutronics
from armi.physics.neutronics.const import CONF_CROSS_SECTION
Expand All @@ -33,7 +33,6 @@
from armi.tests import TEST_ROOT
from armi.tests.test_plugins import TestPlugin
from armi.utils import directoryChangers
from armi import getPluginManagerOrFail, settings, tests

XS_EXAMPLE = """AA:
geometry: 0D
Expand Down
5 changes: 2 additions & 3 deletions armi/reactor/converters/tests/test_geometryConverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
from numpy.testing import assert_allclose

from armi import runLog
from armi import settings
from armi.reactor import blocks
from armi.reactor import geometry
from armi.reactor import grids
from armi.tests import TEST_ROOT
from armi.reactor.converters import geometryConverters
from armi.reactor.converters import uniformMesh
from armi.reactor.tests.test_reactors import loadTestReactor, reduceTestReactorRings
from armi.reactor.flags import Flags
from armi.reactor.tests.test_reactors import loadTestReactor, reduceTestReactorRings
from armi.tests import TEST_ROOT
from armi.utils import directoryChangers


Expand Down
11 changes: 11 additions & 0 deletions armi/reactor/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,17 @@ def test_setMassFrac(self):
self.fuel.setMassFrac("U235", target35)
self.assertAlmostEqual(self.fuel.getMassFrac("U235"), target35)

def test_adjustMassFrac_invalid(self):
with self.assertRaises(ValueError):
self.fuel.adjustMassFrac(nuclideToAdjust="ZR", val=-0.23)

with self.assertRaises(ValueError):
self.fuel.adjustMassFrac(nuclideToAdjust="ZR", val=1.12)

alwaysFalse = lambda a: False
self.fuel.parent = None
self.assertIsNone(self.fuel.getAncestorAndDistance(alwaysFalse))

def test_adjustMassFrac_U235(self):
zrMass = self.fuel.getMass("ZR")
uMass = self.fuel.getMass("U")
Expand Down
5 changes: 5 additions & 0 deletions armi/reactor/tests/test_composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def test_getReactionRates(self):
self.assertEqual(len(rRates), 6)
self.assertEqual(sum([r for r in rRates.values()]), 0)

def test_syncParameters(self):
data = [{"serialNum": 123}, {"flags": "FAKE"}]
numSynced = self.container._syncParameters(data, {})
self.assertEqual(numSynced, 2)


class TestCompositeTree(unittest.TestCase):

Expand Down
11 changes: 11 additions & 0 deletions armi/tests/test_mpiActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def tearDown(self):
context.MPI_SIZE = self._mpiSize
context.MPI_RANK = 0

def test_parallel(self):
self.action.serial = False
self.assertTrue(self.action.parallel)

self.action.serial = True
self.assertFalse(self.action.parallel)

def test_serialGather(self):
self.action.serial = True
self.assertEqual(len(self.action.gather()), 1)

def test_mpiIter(self):
allObjs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
distObjs = [[0, 1, 2], [3, 4, 5], [6, 7], [8, 9], [10, 11]]
Expand Down
1 change: 0 additions & 1 deletion armi/utils/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Test armi.utils.units.py"""
# pylint: disable=missing-function-docstring,missing-class-docstring,protected-access,invalid-name,no-self-use,no-method-argument,import-outside-toplevel
import math
import unittest

from armi.utils import units
Expand Down

0 comments on commit 5d8d7c6

Please sign in to comment.