def test_fat32_windowing(self): def fatcompare(s, t): x = int(s) - int(t) if x >= 2: return 1 elif x <= -2: return -1 return 0 m = mod.compute_synchronization( {"/a":1}, "/", {"/target/a":0}, "/target", time_comparator=fatcompare) self.assertEquals(m[0], {}) m = mod.compute_synchronization( {"/a":2}, "/", {"/target/a":1}, "/target", time_comparator=fatcompare) self.assertEquals(m[0], {}) m = mod.compute_synchronization( {"/a":1}, "/", {"/target/a":2}, "/target", time_comparator=fatcompare) self.assertEquals(m[0], {}) m = mod.compute_synchronization( {"/a":4}, "/", {"/target/a":2}, "/target", time_comparator=fatcompare) self.assertEquals(m[0], {"/a":"/target/a"})
def test_mapper(self): mapper = lambda x, y: x.replace("a", "b") m = mod.compute_synchronization( {"/a":1}, "/", {"/target/b":1}, "/target", path_mapper=mapper) self.assertEquals(m[0], {}) m = mod.compute_synchronization( {"/a":1}, "/", {"/target/b":0}, "/target", path_mapper=mapper) self.assertEquals(m[0], {"/a": "/target/b"})
def test_absent_source(self): m = mod.compute_synchronization( {}, "/", {}, "/target") self.assertEquals(m[0], {})
def test_absent_target(self): m = mod.compute_synchronization( {"/a":1}, "/", {}, "/target") self.assertEquals(m[0], {"/a": "/target/a"})
def test_identical(self): m = mod.compute_synchronization( {"/a":1}, "/", {"/target/a":1}, "/target") self.assertEquals(m[0], {})
def test_complex(self): s = {"/source/abc":45, "/source/def":30} t = {} sp = "/" tp = "/target" e = { "/source/abc":"/target/source/abc", "/source/def":"/target/source/def", } m = mod.compute_synchronization(s, sp, t, tp) self.assertEquals(m[0], e) sp = "/source" e = { "/source/abc":"/target/abc", "/source/def":"/target/def", } m = mod.compute_synchronization(s, sp, t, tp) self.assertEquals(m[0], e) sp = "/source/" m = mod.compute_synchronization(s, sp, t, tp) self.assertEquals(m[0], e) tp = "/target/" m = mod.compute_synchronization(s, sp, t, tp) self.assertEquals(m[0], e) sp = "/source" m = mod.compute_synchronization(s, sp, t, tp) self.assertEquals(m[0], e) sp = "/source/a" e = { "/source/abc":"/target/../abc", "/source/def":"/target/../def", } self.assertRaises(ValueError, lambda: mod.compute_synchronization(s, sp, t, tp))
def test_simple_case(self): m = mod.compute_synchronization({}, "/", {}, "/") self.assertEquals(m, ({}, {}, {}))