def test_unnamed_named_link_same_type(self): """Test get_target_type when a group contains both an unnamed and named link with type X.""" child0 = LinkSpec(doc='Group 0', target_type='Type0') child1 = LinkSpec(doc='Group 1', target_type='Type0', name='type1') parent_spec = GroupSpec(doc='A test group', name='parent', links=[child0, child1], data_type_def='ParentType') self.assertIs(parent_spec.get_target_type('Type0'), child0)
def test_unnamed_dataset_link_same_type(self): child = DatasetSpec(doc='Dataset 0', data_type_inc='Type0') link = LinkSpec(doc='Link 0', target_type='Type0') parent_spec = GroupSpec(doc='A test group', name='parent', datasets=[child], links=[link], data_type_def='ParentType') self.assertIs(parent_spec.get_data_type('Type0'), child) self.assertIs(parent_spec.get_target_type('Type0'), link)
def test_two_named_links_same_type(self): """Test get_target_type when a group contains multiple named links with type X.""" child0 = LinkSpec(doc='Group 0', target_type='Type0', name='group0') child1 = LinkSpec(doc='Group 1', target_type='Type0', name='group1') parent_spec = GroupSpec(doc='A test group', name='parent', links=[child0, child1], data_type_def='ParentType') self.assertEqual(parent_spec.get_target_type('Type0'), [child0, child1])