Beispiel #1
0
 def testAddObjectSetsStorageInChild(self):
     parent = MtpObject(self.default_data, self.get_default_info())
     uut = MtpObject(self.default_data, self.get_default_info())
     storage = self.get_default_storage()
     parent.set_storage(storage)
     parent.add_object(uut)
     self.assertEqual(uut.storage, storage)
     self.assertEqual(parent.storage, storage)
Beispiel #2
0
 def testAddObjectSetsStorageInChild(self):
     parent = MtpObject(self.default_data, self.get_default_info())
     uut = MtpObject(self.default_data, self.get_default_info())
     storage = self.get_default_storage()
     parent.set_storage(storage)
     parent.add_object(uut)
     self.assertEqual(uut.storage, storage)
     self.assertEqual(parent.storage, storage)
Beispiel #3
0
 def testSetStorageIsRecursive(self):
     '''
     .. todo:: should this be in storage tests? (TBD)
     '''
     parent = MtpObject(self.default_data, self.get_default_info())
     storage = self.get_default_storage()
     uut = MtpObject(self.default_data, self.get_default_info())
     parent.add_object(uut)
     parent.set_storage(storage)
     self.assertEqual(uut.storage, storage)
     self.assertEqual(parent.storage, storage)
Beispiel #4
0
 def testGetObjectChildren(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     obj = uut.get_object(others[0].get_uid())
     self.assertEqual(obj, others[0])
Beispiel #5
0
 def testGetObjectSelfWithChilds(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     obj = uut.get_object(uut.get_uid())
     self.assertEqual(uut, obj)
Beispiel #6
0
 def testSetStorageIsRecursive(self):
     '''
     .. todo:: should this be in storage tests? (TBD)
     '''
     parent = MtpObject(self.default_data, self.get_default_info())
     storage = self.get_default_storage()
     uut = MtpObject(self.default_data, self.get_default_info())
     parent.add_object(uut)
     parent.set_storage(storage)
     self.assertEqual(uut.storage, storage)
     self.assertEqual(parent.storage, storage)
Beispiel #7
0
 def testGetObjectChildren(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     obj = uut.get_object(others[0].get_uid())
     self.assertEqual(obj, others[0])
Beispiel #8
0
 def testGetObjectSelfWithChilds(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     obj = uut.get_object(uut.get_uid())
     self.assertEqual(uut, obj)
Beispiel #9
0
 def testGetObjectsWithMultipleChildes(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     objs = uut.get_objects()
     self.assertEqual(len(objs), len(set(objs)))
     self.assertEqual(len(objs), len(others))
     self.assertEqual(set(objs), set(others))
Beispiel #10
0
 def testGetObjectsWithMultipleChildes(self):
     others = [
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info()),
         MtpObject(self.default_data, self.get_default_info())
     ]
     uut = MtpObject(self.default_data, self.get_default_info())
     for obj in others:
         uut.add_object(obj)
     objs = uut.get_objects()
     self.assertEqual(len(objs), len(set(objs)))
     self.assertEqual(len(objs), len(others))
     self.assertEqual(set(objs), set(others))
Beispiel #11
0
 def testAddObjectSetsParent(self):
     parent = MtpObject(self.default_data, self.get_default_info())
     uut = MtpObject(self.default_data, self.get_default_info())
     parent.add_object(uut)
     self.assertEqual(uut.parent, parent)
Beispiel #12
0
 def testAddObjectSetsParent(self):
     parent = MtpObject(self.default_data, self.get_default_info())
     uut = MtpObject(self.default_data, self.get_default_info())
     parent.add_object(uut)
     self.assertEqual(uut.parent, parent)