def test_repos(self): """Test the creation, deletion, and querying of repos. """ dbdir = tempfile.mkdtemp() store = DicedStore(dbdir, port=10000, rpcport=10001) try: store.create_repo("myrepo") store.create_repo("myrepo1") # make sure duplicate repos cannot be added try: store.create_repo("myrepo1") except DicedException: pass # Good, should not be able to create duplicate repo else: assert False, "Expected an exception above, but it wasn't raised!" # grab repo names reponames = store.list_repos() self.assertEqual(len(reponames), 2) nameonly = [] for (name, uuid) in reponames: nameonly.append(name) self.assertTrue("myrepo" in nameonly) self.assertTrue("myrepo1" in nameonly) # delete repo and check repo list store.delete_repo("myrepo") reponames = store.list_repos() self.assertEqual(len(reponames), 1) nameonly = [] for (name, uuid) in reponames: nameonly.append(name) self.assertFalse("myrepo" in nameonly) self.assertTrue("myrepo1" in nameonly) # test get uuid interface uuid = store.get_repouuid("myrepo1") self.assertEqual(uuid, reponames[0][1]) # retrieve DicedRepo object repo = store.open_repo("myrepo1") finally: store._shutdown_store() shutil.rmtree(dbdir)
def test_repoversion(self): """Check versioning in repos. This test creates a repo and creates different versions. """ # create store object and repo dbdir = tempfile.mkdtemp() store = DicedStore(dbdir) try: # my initial repo store.create_repo("myrepo") myrepo = store.open_repo("myrepo") # check current version uuid = myrepo.get_current_version() uuid2 = store.list_repos()[0][1] self.assertEqual(uuid, uuid2) # check lock status self.assertFalse(myrepo.locked) # check branch on open node is illegal try: myrepo.create_branch("start") except DicedException: pass else: assert False, "Expected an exception above, but it wasn't raised!" # lock node myrepo.lock_node("now done") self.assertTrue(myrepo.locked) # create new branch uuidnew = myrepo.create_branch("start") self.assertNotEqual(uuid, uuidnew) # open repo with uuid myrepov2 = store.open_repo(uuid=uuidnew) self.assertEqual(myrepov2.get_current_version(), uuidnew) # check log history logs = myrepov2.get_commit_log() self.assertEqual(logs[0][0], uuid) self.assertEqual(logs[0][1], "now done") self.assertEqual(logs[1][0], uuidnew) self.assertEqual(logs[1][1], "(open node)") # change version myrepo.change_version(uuidnew) self.assertFalse(myrepo.locked) self.assertEqual(myrepo.uuid, uuidnew) finally: store._shutdown_store() shutil.rmtree(dbdir)