def test_two_named_group_same_type(self): """Test get_data_type when a group contains multiple named groups with type X.""" child0 = GroupSpec(doc='Group 0', data_type_inc='Type0', name='group0') child1 = GroupSpec(doc='Group 1', data_type_inc='Type0', name='group1') parent_spec = GroupSpec(doc='A test group', name='parent', groups=[child0, child1], data_type_def='ParentType') self.assertEqual(parent_spec.get_data_type('Type0'), [child0, child1])
def test_unnamed_named_group_same_type(self): """Test get_data_type when a group contains both an unnamed and named group with type X.""" child0 = GroupSpec(doc='Group 0', data_type_inc='Type0') child1 = GroupSpec(doc='Group 1', data_type_inc='Type0', name='type1') parent_spec = GroupSpec(doc='A test group', name='parent', groups=[child0, child1], data_type_def='ParentType') self.assertIs(parent_spec.get_data_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_named_unnamed_dataset_with_def_same_type(self): """Test get_data_type when a group contains both a named and unnamed dataset with type X.""" child0 = DatasetSpec(doc='Group 0', data_type_def='Type0', name='type0') child1 = DatasetSpec(doc='Group 1', data_type_inc='Type0') parent_spec = GroupSpec(doc='A test group', name='parent', datasets=[child0, child1], data_type_def='ParentType') self.assertIs(parent_spec.get_data_type('Type0'), child1)
def test_three_named_datasets_same_type(self): """Test get_target_type when a group contains three named links with type X.""" child0 = DatasetSpec(doc='Group 0', data_type_inc='Type0', name='group0') child1 = DatasetSpec(doc='Group 1', data_type_inc='Type0', name='group1') child2 = DatasetSpec(doc='Group 2', data_type_inc='Type0', name='group2') parent_spec = GroupSpec(doc='A test group', name='parent', datasets=[child0, child1, child2], data_type_def='ParentType') self.assertEqual(parent_spec.get_data_type('Type0'), [child0, child1, child2])