def test_ocp_on_azure_infrastructure_type(self): """Test that the provider infrastructure returns Azure when running on Azure.""" provider_authentication = ProviderAuthentication.objects.create(provider_resource_name='cluster_id_1002') provider = Provider.objects.create(name='ocpprovidername', type='AZURE', created_by=self.user, customer=self.customer, authentication=provider_authentication,) data_generator = OCPAzureReportDataGenerator(self.tenant, provider, current_month_only=True) data_generator.add_data_to_tenant() data_generator.create_ocp_provider(data_generator.cluster_id, data_generator.cluster_alias) provider_uuid = data_generator.provider_uuid manager = ProviderManager(provider_uuid) infrastructure_name = manager.get_infrastructure_name(self.tenant) self.assertEqual(infrastructure_name, 'AZURE') data_generator.remove_data_from_tenant()
def test_filter_by_infrastructure_ocp_on_azure(self): """Test that filter by infrastructure for ocp on azure.""" data_generator = OCPAzureReportDataGenerator( self.tenant, self.provider, current_month_only=True ) data_generator.add_data_to_tenant() data_generator.add_ocp_data_to_tenant() url = '?filter[resolution]=monthly&filter[time_scope_value]=-1&filter[time_scope_units]=month&filter[infrastructures]=azure' # noqa: E501 query_params = self.mocked_query_params(url, OCPCpuView) handler = OCPReportQueryHandler(query_params) query_data = handler.execute_query() self.assertTrue(query_data.get('data')) # check that returned list is not empty for entry in query_data.get('data'): self.assertTrue(entry.get('values')) for value in entry.get('values'): self.assertIsNotNone(value.get('usage').get('value')) self.assertIsNotNone(value.get('request').get('value')) data_generator.remove_data_from_tenant()