示例#1
0
 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")
示例#2
0
 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")
示例#3
0
 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")
示例#4
0
 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")
示例#5
0
 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")
示例#6
0
 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")
示例#7
0
 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")
示例#8
0
 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")
示例#9
0
 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" )