Exemplo n.º 1
0
    def test_schema_name_present_on_customer(self):
        """Test that schema_name is returned on customer."""
        iam_arn = 'arn:aws:s3:::my_s3_bucket'
        bucket_name = 'my_s3_bucket'
        provider = {
            'name': 'test_provider',
            'type': Provider.PROVIDER_AWS,
            'authentication': {
                'provider_resource_name': iam_arn
            },
            'billing_source': {
                'bucket': bucket_name
            }
        }

        with patch.object(ProviderAccessor,
                          'cost_usage_source_ready',
                          returns=True):
            serializer = AdminProviderSerializer(data=provider,
                                                 context=self.request_context)
            if serializer.is_valid(raise_exception=True):
                serializer.save()

        account = self.customer.account_id
        expected_schema_name = create_schema_name(account)
        schema_name = serializer.data['customer'].get('schema_name')
        self.assertIsNotNone(schema_name)
        self.assertEqual(schema_name, expected_schema_name)
Exemplo n.º 2
0
    def test_schema_name_present_on_customer(self):
        """Test that schema_name is returned on customer."""
        iam_arn = "arn:aws:s3:::my_s3_bucket"
        bucket_name = "my_s3_bucket"
        provider = {
            "name": "test_provider",
            "type": Provider.PROVIDER_AWS.lower(),
            "authentication": {
                "credentials": {
                    "role_arn": iam_arn
                }
            },
            "billing_source": {
                "data_source": {
                    "bucket": bucket_name
                }
            },
        }

        with patch.object(ProviderAccessor,
                          "cost_usage_source_ready",
                          returns=True):
            serializer = AdminProviderSerializer(data=provider,
                                                 context=self.request_context)
            if serializer.is_valid(raise_exception=True):
                serializer.save()

        account = self.customer.account_id
        expected_schema_name = create_schema_name(account)
        schema_name = serializer.data["customer"].get("schema_name")
        self.assertIsNotNone(schema_name)
        self.assertEqual(schema_name, expected_schema_name)