コード例 #1
0
class TestDatabaseInterface(unittest.TestCase):
    r"""Tests for the DatabaseInterface class"""
    def setUp(self):
        self.td = directoryChangers.TemporaryDirectoryChanger()
        self.td.__enter__()
        self.o, self.r = test_reactors.loadTestReactor(TEST_ROOT)

        self.dbi = DatabaseInterface(self.r, self.o.cs)
        self.dbi.initDB(fName=self._testMethodName + ".h5")
        self.db: db.Database3 = self.dbi.database
        self.stateRetainer = self.r.retainState().__enter__()

    def tearDown(self):
        self.db.close()
        self.stateRetainer.__exit__()
        self.td.__exit__(None, None, None)

    def test_interactBOL(self):
        self.assertIsNotNone(self.dbi._db)
        self.dbi.interactBOL()

        self.dbi._db = None
        self.assertIsNone(self.dbi._db)
        self.dbi.interactBOL()
        self.assertIsNotNone(self.dbi._db)

    def test_distributable(self):
        self.assertEqual(self.dbi.distributable(), 4)
        self.dbi.interactDistributeState()
        self.assertEqual(self.dbi.distributable(), 4)
コード例 #2
0
 def test_badDBName(self):
     cs = settings.Settings(os.path.join(TEST_ROOT, "armiRun.yaml"))
     cs["reloadDBName"] = "aRmIRuN.h5"  # weird casing to confirm robust checking
     dbi = DatabaseInterface(None, cs)
     with self.assertRaises(ValueError):
         # an error should be raised when the database loaded from
         # has the same name as the run to avoid overwriting.
         dbi.initDB()
コード例 #3
0
    def test_badDBName(self):
        cs = settings.Settings(os.path.join(TEST_ROOT, "armiRun.yaml"))
        cs = cs.modified(newSettings={"reloadDBName": "aRmIRuN.h5"})

        dbi = DatabaseInterface(None, cs)
        with self.assertRaises(ValueError):
            # an error should be raised when the database loaded from
            # has the same name as the run to avoid overwriting.
            dbi.initDB()
コード例 #4
0
    def setUp(self):
        self.td = directoryChangers.TemporaryDirectoryChanger()
        self.td.__enter__()
        self.o, self.r = test_reactors.loadTestReactor(TEST_ROOT)

        self.dbi = DatabaseInterface(self.r, self.o.cs)
        self.dbi.initDB(fName=self._testMethodName + ".h5")
        self.db: db.Database3 = self.dbi.database
        self.stateRetainer = self.r.retainState().__enter__()