def test_add_provider_sources_details_not_found(self): """Tests that adding information retrieved from the sources network API is not successful.""" try: test_name = "My Source Name" source_type = Provider.PROVIDER_AWS mock_details = MockDetails(test_name, faker.uuid4(), source_type, 1) storage.add_provider_sources_details(mock_details, self.test_source_id + 1) except Exception as error: self.fail(str(error))
def test_add_provider_sources_details(self): """Tests that adding information retrieved from the sources network API is successful.""" test_source = Sources.objects.get(source_id=self.test_source_id) self.assertIsNone(test_source.name) self.assertEqual(test_source.source_type, "") self.assertEqual(test_source.authentication, {}) test_name = "My Source Name" source_type = Provider.PROVIDER_AWS endpoint_id = 1 source_uuid = faker.uuid4() mock_details = MockDetails(test_name, source_uuid, source_type, endpoint_id) storage.add_provider_sources_details(mock_details, self.test_source_id) test_source = Sources.objects.get(source_id=self.test_source_id) self.assertEqual(test_source.name, test_name) self.assertEqual(test_source.source_type, source_type) self.assertEqual(str(test_source.source_uuid), source_uuid)
def save_sources_details(self): """ Get additional sources context from Sources REST API. Additional details retrieved from the network includes: - Source Name - Source Type - Source UID Details are stored in the Sources database table. """ LOG.info(f"[save_sources_details] starting for source_id {self.source_id} ...") details = self.get_source_details() if not details.source_type: LOG.warning(f"[save_sources_details] unexpected source_type_id: {details.source_type_id}") return result = storage.add_provider_sources_details(details, self.source_id) or False LOG.info(f"[save_sources_details] complete for source_id {self.source_id}: {result}") return result