def test2_changed(self): src = Inventory(resources={'a': 1, 'b': 2}) dst = Inventory(resources={'a': 3, 'b': 4}) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 0, "0 things unchanged") self.assertEqual(changed, ['a', 'b'], "2 things changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test4_added(self): src = Inventory(resources={'a': 1, 'b': 2, 'c': 3, 'd': 4}) dst = Inventory(resources={'a': 1, 'c': 3}) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, ['b', 'd'], "b and d added")
def test4_added(self): src = Inventory(resources={"a": 1, "b": 2, "c": 3, "d": 4}) dst = Inventory(resources={"a": 1, "c": 3}) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, ["b", "d"], "b and d added")
def test2_changed(self): src = Inventory(resources={"a": 1, "b": 2}) dst = Inventory(resources={"a": 3, "b": 4}) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 0, "0 things unchanged") self.assertEqual(changed, ["a", "b"], "2 things changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test1_same(self): data = {'a': 1, 'b': 2} src = Inventory(resources=data) dst = Inventory(resources=data) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test1_same(self): data = {"a": 1, "b": 2} src = Inventory(resources=data) dst = Inventory(resources=data) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test1_same(self): src = Inventory() src.add( Resource('a',timestamp=1) ) src.add( Resource('b',timestamp=2) ) dst = Inventory() dst.add( Resource('a',timestamp=1) ) dst.add( Resource('b',timestamp=2) ) ( num_same, changed, deleted, added ) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test1_same(self): src = Inventory() src.add(Resource('a', timestamp=1)) src.add(Resource('b', timestamp=2)) dst = Inventory() dst.add(Resource('a', timestamp=1)) dst.add(Resource('b', timestamp=2)) (num_same, changed, deleted, added) = dst.compare(src) self.assertEqual(num_same, 2, "2 things unchanged") self.assertEqual(changed, [], "nothing changed") self.assertEqual(deleted, [], "nothing deleted") self.assertEqual(added, [], "nothing added")
def test1_same(self): src = Inventory() src.add( Resource('a',timestamp=1) ) src.add( Resource('b',timestamp=2) ) dst = Inventory() dst.add( Resource('a',timestamp=1) ) dst.add( Resource('b',timestamp=2) ) ( same, changed, deleted, added ) = dst.compare(src) self.assertEqual( len(same), 2, "2 things unchanged" ) i = iter(same) self.assertEqual( i.next().uri, 'a', "first was a" ) self.assertEqual( i.next().uri, 'b', "second was b" ) self.assertEqual( len(changed), 0, "nothing changed" ) self.assertEqual( len(deleted), 0, "nothing deleted" ) self.assertEqual( len(added), 0, "nothing added" )