def test_seed_children_task(self): collection = OrganizationCollectionFactory() concept = ConceptFactory() mapping = MappingFactory() concept_latest_version = concept.get_latest_version() mapping_latest_version = mapping.get_latest_version() collection.add_references([ concept_latest_version.version_url, mapping_latest_version.version_url ]) self.assertEqual(collection.references.count(), 2) self.assertEqual(collection.concepts.count(), 1) self.assertEqual(collection.mappings.count(), 1) collection_v1 = OrganizationCollectionFactory( organization=collection.organization, version='v1', mnemonic=collection.mnemonic) self.assertEqual(collection_v1.references.count(), 0) self.assertEqual(collection_v1.concepts.count(), 0) self.assertEqual(collection_v1.mappings.count(), 0) seed_children('collection', collection_v1.id) # pylint: disable=no-value-for-parameter self.assertEqual(collection_v1.references.count(), 2) self.assertEqual(collection_v1.concepts.count(), 1) self.assertEqual(collection_v1.mappings.count(), 1) self.assertEqual( list(collection_v1.references.values_list('expression', flat=True)), list(collection.references.values_list('expression', flat=True)), )
def test_seed_children_task_with_export(self, export_source_task, index_children_mock): source = OrganizationSourceFactory() ConceptFactory(parent=source) MappingFactory(parent=source) source_v1 = OrganizationSourceFactory(organization=source.organization, version='v1', mnemonic=source.mnemonic) self.assertEqual(source_v1.concepts.count(), 0) self.assertEqual(source_v1.mappings.count(), 0) seed_children('source', source_v1.id) # pylint: disable=no-value-for-parameter self.assertEqual(source_v1.concepts.count(), 1) self.assertEqual(source_v1.mappings.count(), 1) export_source_task.delay.assert_called_once_with(source_v1.id) index_children_mock.assert_called_once()
def test_seed_children_task(self): source = OrganizationSourceFactory() ConceptFactory(parent=source) MappingFactory(parent=source) source_v1 = OrganizationSourceFactory(organization=source.organization, version='v1', mnemonic=source.mnemonic) self.assertEqual(source_v1.concepts.count(), 0) self.assertEqual(source_v1.mappings.count(), 0) seed_children('source', source_v1.id) # pylint: disable=no-value-for-parameter self.assertEqual(source_v1.concepts.count(), 1) self.assertEqual(source_v1.mappings.count(), 1)