def test_multiple_types(self): tdb = TemporaryDatabase("txn:git:hash\n") ddir = tdb.ddir db = Database.load(ddir.name) db.records()[:] = [Record([1, 2, 3])] db.store() self.assertEqual(set(db.schema().transaction_types()), set(["git", "hash"]))
def do_test(self, expected, schema, configv): tdb = TemporaryDatabase(schema) ddir2 = tempfile.TemporaryDirectory() config = "%s/config" % ddir2.name with open(config, "w") as fp: fp.write("fmt:3:newfol config file:\n" + configv) db = Database.load(tdb.ddir.name, extra_config=[config]) db.records()[:] = [Record([1, 2, 3])] db.store() self.assertEqual(db.schema().execution_allowed(), expected) ddir2.cleanup()
def test_existing_config_file(self): tdb = TemporaryDatabase() ddir2 = tempfile.TemporaryDirectory() config = "%s/config" % ddir2.name with open(config, "w") as fp: fp.write("fmt:3:newfol config file:\ntxn:git:hash\n") db = Database.load(tdb.ddir.name, extra_config=[config]) db.records()[:] = [Record([1, 2, 3])] db.store() self.assertEqual(set(db.schema().transaction_types()), set(["git", "hash"])) ddir2.cleanup()
def db(self): return Database.load(self.ddir.name)
def test_missing_config_file(self): tdb = TemporaryDatabase() config = "%s/config" % tdb.ddir.name db = Database.load(tdb.ddir.name, extra_config=[config]) db.records()[:] = [Record([1, 2, 3])] db.store()