def test_multiple_repos(self): """coherency when several repos in use""" document = CacheDocument() # create 2 repos document.add_repository(os.sep.join([TEST_DIR, "data", "profiles"])) tag_files(document, os.sep.join([TEST_DIR, "data", "profiles"]), ["bruce.prf", ".svn"], u"first") document.share_files(os.sep.join([TEST_DIR, "data", "profiles"]), ["bruce.prf", "demi.prf"], True) document.add_repository(os.sep.join([TEST_DIR, "data", "subdir1"])) tag_files(document, os.sep.join([TEST_DIR, "data", "subdir1"]), ["date.doc", ".svn"], u"second") document.share_files(os.sep.join([TEST_DIR, "data", "subdir1"]), ["date.doc", "subsubdir"], True) # check sharing state self.assertEquals(document.get_container( abspath(os.sep.join(["data", "profiles", "bruce.prf"])))._shared, True) self.assertEquals(document.get_container( abspath(os.sep.join(["data", "profiles", "demi.prf"])))._shared, True) self.assertEquals(document.get_container( abspath(os.sep.join(["data", "profiles", ".svn"])))._shared, False) self.assertEquals(document.get_container( abspath(os.sep.join(["data", "subdir1", "date.doc"])))._shared, True) self.assertEquals(document.get_container( abspath(os.sep.join(["data", "subdir1", "subsubdir"])))._shared, True) self.assertEquals(document.get_container( abspath(os.sep.join(["data", "subdir1", ".svn"])))._shared, False) # check tag self.assertRaises(ContainerException, document.add_repository, os.sep.join([TEST_DIR, "data", "subdir1", "subsubdir"])) self.assertRaises(ContainerException, document.add_repository, os.sep.join([TEST_DIR, "data"]))
def test_get_shared_files(self): document = CacheDocument() document.add_repository(TEST_DIR) document.expand_dir(abspath("data")) document.expand_dir(abspath(os.path.join("data", "subdir1"))) document.share_files(abspath("data"), [os.sep.join([TEST_DIR, "data", ".path"]), os.sep.join([TEST_DIR, "data", ".svn"]), os.sep.join([TEST_DIR, "data", "date.txt"]), os.sep.join([TEST_DIR, "data", "emptydir"]), os.sep.join([TEST_DIR, "data", "profiles"]), os.sep.join([TEST_DIR, "data", "subdir1", ".svn"]), os.sep.join([TEST_DIR, "data", "subdir1", "subsubdir"])], False) document.share_files(abspath("data"), [os.sep.join([TEST_DIR, "data"]), os.sep.join([TEST_DIR, "data", ".path"]), os.sep.join([TEST_DIR, "data", "date.txt"]), os.sep.join([TEST_DIR, "data", "routage"]), os.sep.join([TEST_DIR, "data", "subdir1"]), os.sep.join([TEST_DIR, "data", "subdir1", "TOtO.txt"]), os.sep.join([TEST_DIR, "data", "subdir1", "date.doc"])], True) shared_files = [file_container.get_path() for file_container in document.get_shared_files()[TEST_DIR]] shared_files.sort() self.assertEquals(shared_files, [os.sep.join([TEST_DIR, "data", ".path"]), os.sep.join([TEST_DIR, "data", "02_b_1280x1024.jpg"]), os.sep.join([TEST_DIR, "data", "Python-2.3.5.zip"]), os.sep.join([TEST_DIR, "data", "arc en ciel 6.gif"]), os.sep.join([TEST_DIR, "data", "date.txt"]), os.sep.join([TEST_DIR, "data", "pywin32-203.win32-py2.3.exe"]), os.sep.join([TEST_DIR, "data", "routage"]), os.sep.join([TEST_DIR, "data", "subdir1", "TOtO.txt"]), os.sep.join([TEST_DIR, "data", "subdir1", "date.doc"])])