def __map_datacatalog_relationships(cls, assembled_entries_dict): all_assembled_entries = [] for assembled_entries_data in assembled_entries_dict.values(): all_assembled_entries.extend(assembled_entries_data) prepare.EntryRelationshipMapper().fulfill_tag_fields( all_assembled_entries)
def test_fulfill_tag_fields_should_resolve_look_query_mapping(self): query_id = 1080 query_entry = self.__make_fake_entry(query_id, 'query') query_tag = self.__make_fake_tag(double_fields=(('id', query_id),)) look_id = 123 look_entry = self.__make_fake_entry(look_id, 'look') double_fields = ('id', look_id), ('query_id', query_id) look_tag = self.__make_fake_tag(double_fields=double_fields) query_assembled_entry = commons_prepare.AssembledEntryData( query_id, query_entry, [query_tag]) look_assembled_entry = commons_prepare.AssembledEntryData( look_id, look_entry, [look_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [look_assembled_entry, query_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{query_entry.name}', look_tag.fields['query_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_dashboard_folder_mapping(self): folder_id = 'test_folder' folder_entry = self.__make_fake_entry(folder_id, 'folder') folder_tag = self.__make_fake_tag(string_fields=(('id', folder_id),)) dashboard_id = 'test_dashboard' dashboard_entry = self.__make_fake_entry(dashboard_id, 'dashboard') string_fields = ('id', dashboard_id), ('folder_id', folder_id) dashboard_tag = self.__make_fake_tag(string_fields=string_fields) folder_assembled_entry = commons_prepare.AssembledEntryData( folder_id, folder_entry, [folder_tag]) dashboard_assembled_entry = commons_prepare.AssembledEntryData( dashboard_id, dashboard_entry, [dashboard_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [folder_assembled_entry, dashboard_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{folder_entry.name}', dashboard_tag.fields['folder_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_folder_parent_mapping(self): parent_id = 'test_parent' parent_entry = self.__make_fake_entry(parent_id, 'folder') parent_tag = self.__make_fake_tag(string_fields=(('id', parent_id),)) folder_id = 'test_folder' folder_entry = self.__make_fake_entry(folder_id, 'folder') string_fields = ('id', folder_id), ('parent_id', parent_id) folder_tag = self.__make_fake_tag(string_fields=string_fields) parent_assembled_entry = commons_prepare.AssembledEntryData( parent_id, parent_entry, [parent_tag]) folder_assembled_entry = commons_prepare.AssembledEntryData( folder_id, folder_entry, [folder_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [parent_assembled_entry, folder_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{parent_entry.name}', folder_tag.fields['parent_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_element_query_mapping(self): query_id = 1080 query_entry = self.__make_fake_entry(query_id, 'query') query_tag = self.__make_fake_tag(double_fields=(('id', query_id),)) element_id = 'test_element' element_entry = self.__make_fake_entry(element_id, 'dashboard_element') double_fields = ('query_id', query_id), element_tag = self.__make_fake_tag(string_fields=(('id', element_id),), double_fields=double_fields) query_assembled_entry = commons_prepare.AssembledEntryData( query_id, query_entry, [query_tag]) element_assembled_entry = commons_prepare.AssembledEntryData( element_id, element_entry, [element_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [query_assembled_entry, element_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{query_entry.name}', element_tag.fields['query_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_element_dashboard_mapping(self): dashboard_id = 'test_dashboard' dashboard_entry = self.__make_fake_entry(dashboard_id, 'dashboard') string_fields = ('id', dashboard_id), dashboard_tag = self.__make_fake_tag(string_fields=string_fields) element_id = 'test_element' element_entry = self.__make_fake_entry(element_id, 'dashboard_element') string_fields = ('id', element_id), ('dashboard_id', dashboard_id) element_tag = self.__make_fake_tag(string_fields=string_fields) dashboard_assembled_entry = commons_prepare.AssembledEntryData( dashboard_id, dashboard_entry, [dashboard_tag]) element_assembled_entry = commons_prepare.AssembledEntryData( element_id, element_entry, [element_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [dashboard_assembled_entry, element_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{dashboard_entry.name}', element_tag.fields['dashboard_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_look_folder_mapping(self): folder_id = 'test_folder' folder_entry = self.__make_fake_entry(folder_id, 'folder') folder_tag = self.__make_fake_tag(string_fields=(('id', folder_id),)) look_id = 123 look_entry = self.__make_fake_entry(look_id, 'look') string_fields = ('folder_id', folder_id), look_tag = self.__make_fake_tag(string_fields=string_fields, double_fields=(('id', look_id),)) folder_assembled_entry = commons_prepare.AssembledEntryData( folder_id, folder_entry, [folder_tag]) look_assembled_entry = commons_prepare.AssembledEntryData( look_id, look_entry, [look_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [folder_assembled_entry, look_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/' f'{folder_entry.name}', look_tag.fields['folder_entry'].string_value)
def test_fulfill_tag_fields_should_resolve_element_look_mapping(self): look_id = 123 look_entry = self.__make_fake_entry(look_id, 'look') look_tag = self.__make_fake_tag(double_fields=(('id', look_id), )) element_id = 'test_element' element_entry = self.__make_fake_entry(element_id, 'dashboard_element') double_fields = ('look_id', look_id), element_tag = self.__make_fake_tag(string_fields=(('id', element_id), ), double_fields=double_fields) look_assembled_entry = commons_prepare.AssembledEntryData( look_id, look_entry, [look_tag]) element_assembled_entry = commons_prepare.AssembledEntryData( element_id, element_entry, [element_tag]) prepare.EntryRelationshipMapper().fulfill_tag_fields( [look_assembled_entry, element_assembled_entry]) self.assertEqual( f'https://console.cloud.google.com/datacatalog/{look_entry.name}', element_tag.fields['look_entry'].string_value)