def test_count_links(self): entity_map = EntityMap() # no element self.assertEqual(entity_map.count_links(), 0) # has 1 element without links entity_map.add_entity(Entity('product', 'product_0', {})) self.assertEqual(entity_map.count_links(), 0) # has 1 element with links entity_map.add_entity( Entity('product', 'product_1', {}, direct_links=[{}, {}, {}])) self.assertEqual(entity_map.count_links(), 3) # has many element with links entity_map.add_entity( Entity('product', 'product_2', {}, direct_links=[{}, {}, {}, {}])) self.assertEqual(entity_map.count_links(), 7)
def define_manifest(self, entity_map: EntityMap): # TODO provide a better way to serialize manifest_json = { 'totalCount': entity_map.count_total(), 'expectedBiomaterials': entity_map.count_entities_of_type('biomaterial'), 'expectedProcesses': entity_map.count_entities_of_type('process'), 'expectedFiles': entity_map.count_entities_of_type('file'), 'expectedProtocols': entity_map.count_entities_of_type('protocol'), 'expectedProjects': entity_map.count_entities_of_type('project'), 'expectedLinks': entity_map.count_links(), 'actualLinks': 0 } self.manifest = self.ingest_api.create_submission_manifest( self.submission_url, manifest_json) return self.manifest