def test_no_children_add(self): """ ChildContainer: NO CHILDREN ADD ------------------------------- Should throw an exception upon trying to get children """ schema = {'contains': []} mongo_doc = {'children': {}} c = ChildContainer('parent_1', mongo_doc) c.add(Frame, 'child_1')
def test_no_children_add(self): """ ChildContainer: NO CHILDREN ADD ------------------------------- Should throw an exception upon trying to get children """ schema = {'contains':[]} mongo_doc = {'children':{}} c = ChildContainer('parent_1', mongo_doc) c.add(Frame, 'child_1')
def test_single_childtype_delete(self): """ ChildContainer: SINGLE CHILDTYPE DELETE ---------------------------------------- Constructs a ChildContainer with a single childtype, tests delete method """ schema = {'contains': [Frame]} mongo_doc = {'children': {}} mongo_doc['children'] = {'Frame': {'frame_1': 'parent_id/frame_1'}} c = ChildContainer('parent_id', schema, mongo_doc) c.add(Frame, 'frame_2') c.delete('frame_2') self.get('frame_2')
def test_single_childtype_delete(self): """ ChildContainer: SINGLE CHILDTYPE DELETE ---------------------------------------- Constructs a ChildContainer with a single childtype, tests delete method """ schema = {'contains':[Frame]} mongo_doc = {'children':{}} mongo_doc['children'] = {'Frame':{'frame_1':'parent_id/frame_1'}} c = ChildContainer('parent_id', schema, mongo_doc) c.add(Frame, 'frame_2') c.delete('frame_2') self.get('frame_2')
def test_multiple_childtype_add(self): """ ChildContainer: MULTIPLE_CHILDTYPE_ADD -------------------------------------- Constructs a ChildContainer with multiple childtypes, tests add method """ schema = {'contains': [Frame, Video]} mongo_doc = {'children': {}} mongo_doc['children']['Frame'] = {'frame_1': 'parent_id/frame_1'} mongo_doc['children']['Video'] = {'video_1': 'parent_id/video_1'} c = ChildContainer('parent_id', schema, mongo_doc) c.add(Frame, 'frame_2') c.add(Video, 'video_2') self.assertEqual(c.get(Frame, 'frame_2')[0], Frame) self.assertEqual(c.get(Frame, 'frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get(Video, 'video_2')[0], Video) self.assertEqual(c.get(Video, 'video_2')[1], 'parent_id/video_2')
def test_multiple_childtype_add(self): """ ChildContainer: MULTIPLE_CHILDTYPE_ADD -------------------------------------- Constructs a ChildContainer with multiple childtypes, tests add method """ schema = {'contains':[Frame, Video]} mongo_doc = {'children':{}} mongo_doc['children']['Frame'] = {'frame_1':'parent_id/frame_1'} mongo_doc['children']['Video'] = {'video_1':'parent_id/video_1'} c = ChildContainer('parent_id', schema, mongo_doc) c.add(Frame, 'frame_2') c.add(Video, 'video_2') self.assertEqual(c.get(Frame, 'frame_2')[0], Frame) self.assertEqual(c.get(Frame, 'frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get(Video, 'video_2')[0], Video) self.assertEqual(c.get(Video, 'video_2')[1], 'parent_id/video_2')
def test_single_childtype_add(self): """ ChildContainer: SINGLE CHILDTYPE ADD ------------------------------------ Constructs a ChildContainer with a single childtype, tests add method """ schema = {'contains': [Frame]} mongo_doc = {'children': {}} mongo_doc['children'] = {'Frame': {'frame_1': 'parent_id/frame_1'}} c = ChildContainer('parent_id', schema, mongo_doc) c.add('frame_2') c.add(Frame, 'frame_3') self.assertEqual(c.get('frame_2')[0], Frame) self.assertEqual(c.get('frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get(Frame, 'frame_2')[0], Frame) self.assertEqual(c.get(Frame, 'frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get('frame_3')[0], Frame) self.assertEqual(c.get('frame_3')[1], 'parent_id/frame_3') self.assertEqual(c.get(Frame, 'frame_3')[0], Frame) self.assertEqual(c.get(Frame, 'frame_3')[1], 'parent_id/frame_3')
def test_single_childtype_add(self): """ ChildContainer: SINGLE CHILDTYPE ADD ------------------------------------ Constructs a ChildContainer with a single childtype, tests add method """ schema = {'contains':[Frame]} mongo_doc = {'children':{}} mongo_doc['children'] = {'Frame':{'frame_1':'parent_id/frame_1'}} c = ChildContainer('parent_id', schema, mongo_doc) c.add('frame_2') c.add(Frame, 'frame_3') self.assertEqual(c.get('frame_2')[0], Frame) self.assertEqual(c.get('frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get(Frame, 'frame_2')[0], Frame) self.assertEqual(c.get(Frame, 'frame_2')[1], 'parent_id/frame_2') self.assertEqual(c.get('frame_3')[0], Frame) self.assertEqual(c.get('frame_3')[1], 'parent_id/frame_3') self.assertEqual(c.get(Frame, 'frame_3')[0], Frame) self.assertEqual(c.get(Frame, 'frame_3')[1], 'parent_id/frame_3')