Exemple #1
0
    def test_create_duplicated_provider(self, *args):
        params = {
            'provider': 'duplicated_provider',
            'name': 'Duplicated Provider',
            'domain_id': self.domain_id
        }

        self.transaction.method = 'create'
        provider_svc = ProviderService(transaction=self.transaction)
        provider_svc.create(params.copy())

        with self.assertRaises(ERROR_SAVE_UNIQUE_VALUES) as e:
            provider_svc = ProviderService(transaction=self.transaction)
            provider_svc.create(params.copy())
Exemple #2
0
    def test_create_provider(self, *args):
        params = {
            'provider': 'DK corp',
            'name': 'AWS',
            'template': {
                'service_account': {
                    'schema': {
                        'type': 'object',
                        'properties': {
                            'account_id': {
                                'title': 'Account ID',
                                'type': 'string'
                            }
                        },
                        'required': ['account_id']
                    }
                }
            },
            'metadata': {
                'view': {
                    'layouts': {
                        'help:service_account:create': {
                            'name': 'Creation Help',
                            'type': 'markdown',
                            'options': {
                                'markdown': {
                                    'en':
                                    ('### Finding Your AWS Account ID\n'
                                     'You can find your account ID in the AWS Management Console, or using the AWS CLI or AWS API.\n'
                                     '#### Finding your account ID (Console)\n'
                                     'In the navigation bar, choose **Support**, and then **Support Center**. '
                                     'Your currently signed-in 12-digit account number (ID) appears in the **Support Center** title bar.'
                                     )
                                }
                            }
                        }
                    }
                }
            },
            'capability': {
                'supported_schema': ['schema-aaa', 'schema-bbb']
            },
            'tags': [{
                'key': 'tag_key',
                'value': 'tag_value'
            }],
            'domain_id': self.domain_id
        }

        self.transaction.method = 'create'
        provider_svc = ProviderService(transaction=self.transaction)
        provider_vo = provider_svc.create(params.copy())

        print_data(provider_vo.to_dict(), 'test_create_provider')
        ProviderInfo(provider_vo)

        self.assertIsInstance(provider_vo, Provider)
        self.assertEqual(params['provider'], provider_vo.provider)
        self.assertEqual(params['name'], provider_vo.name)
        self.assertEqual(params['template'], provider_vo.template)
        self.assertEqual(params['metadata'], provider_vo.metadata)
        self.assertEqual(params['capability'], provider_vo.capability)
        self.assertEqual(params['tags'], provider_vo.to_dict()['tags'])