def test_ocp_infrastructure_type_error(self): """Test that the provider infrastructure returns Unknown when running stand alone.""" provider_authentication = ProviderAuthentication.objects.create( provider_resource_name='cluster_id_1001') provider = Provider.objects.create( name='ocpprovidername', type=Provider.PROVIDER_OCP, created_by=self.user, customer=self.customer, authentication=provider_authentication, ) data_generator = OCPAWSReportDataGenerator(self.tenant, provider, current_month_only=True) data_generator.create_ocp_provider('cool-cluster-id', 'awesome-alias') provider_uuid = data_generator.provider_uuid manager = ProviderManager(provider_uuid) with patch.object(ProviderAccessor, 'infrastructure_type', side_effect=ProviderAccessorError('mock_error')): infrastructure_name = manager.get_infrastructure_name(self.tenant) self.assertEqual(infrastructure_name, 'Unknown-Error') data_generator.remove_data_from_tenant()
def test_ocp_infrastructure_type(self): """Test that the provider infrastructure returns Unknown when running stand alone.""" provider_authentication = ProviderAuthentication.objects.create( provider_resource_name='cluster_id_1001') provider = Provider.objects.create( name='ocpprovidername', type=Provider.PROVIDER_OCP, created_by=self.user, customer=self.customer, authentication=provider_authentication, ) ocp_aws_data_generator = OCPAWSReportDataGenerator( self.tenant, provider, current_month_only=True) data_generator = OCPReportDataGenerator(self.tenant, provider, current_month_only=True) data_generator.add_data_to_tenant() ocp_aws_data_generator.create_ocp_provider( data_generator.cluster_id, data_generator.cluster_alias) provider_uuid = ocp_aws_data_generator.provider_uuid manager = ProviderManager(provider_uuid) infrastructure_name = manager.get_infrastructure_name(self.tenant) self.assertEqual(infrastructure_name, 'Unknown') data_generator.remove_data_from_tenant() ocp_aws_data_generator.remove_data_from_tenant()
def test_ocp_infrastructure_type_error(self): """Test that the provider infrastructure returns Unknown when running stand alone.""" data_generator = OCPAWSReportDataGenerator(self.tenant, current_month_only=True) data_generator.create_ocp_provider('cool-cluster-id', 'awesome-alias') provider_uuid = data_generator.provider_uuid manager = ProviderManager(provider_uuid) with patch.object(ProviderAccessor, 'infrastructure_type', side_effect=ProviderAccessorError('mock_error')): infrastructure_name = manager.get_infrastructure_name(self.tenant) self.assertEqual(infrastructure_name, 'Unknown-Error') data_generator.remove_data_from_tenant()
def test_ocp_on_aws_infrastructure_type(self): """Test that the provider infrastructure returns AWS when running on AWS.""" data_generator = OCPAWSReportDataGenerator(self.tenant, current_month_only=True) data_generator.add_data_to_tenant() data_generator.add_aws_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, 'AWS') data_generator.remove_data_from_tenant()
def test_ocp_infrastructure_type_error(self): """Test that the provider infrastructure returns Unknown when running stand alone.""" provider_authentication = ProviderAuthentication.objects.create(provider_resource_name="cluster_id_1001") provider = Provider.objects.create( name="ocpprovidername", type=Provider.PROVIDER_OCP, created_by=self.user, customer=self.customer, authentication=provider_authentication, ) data_generator = OCPAWSReportDataGenerator(self.tenant, provider, current_month_only=True) data_generator.create_ocp_provider("cool-cluster-id", "awesome-alias") provider_uuid = data_generator.provider_uuid manager = ProviderManager(provider_uuid) infrastructure_name = manager.get_infrastructure_name() self.assertEqual(infrastructure_name, "Unknown") data_generator.remove_data_from_tenant()
def test_ocp_on_aws_infrastructure_type(self): """Test that the provider infrastructure returns AWS when running on AWS.""" provider_authentication = ProviderAuthentication.objects.create(provider_resource_name="cluster_id_1001") provider = Provider.objects.create( name="ocpprovidername", type=Provider.PROVIDER_AWS, created_by=self.user, customer=self.customer, authentication=provider_authentication, ) data_generator = OCPAWSReportDataGenerator(self.tenant, provider, current_month_only=True) data_generator.add_data_to_tenant() data_generator.add_aws_data_to_tenant() data_generator.create_ocp_provider( data_generator.cluster_id, data_generator.cluster_alias, infrastructure_type=Provider.PROVIDER_AWS ) provider_uuid = data_generator.provider_uuid manager = ProviderManager(provider_uuid) infrastructure_name = manager.get_infrastructure_name() self.assertEqual(infrastructure_name, Provider.PROVIDER_AWS) data_generator.remove_data_from_tenant()