def get_by_name(self, name): aws_accounts = self.list() aws_account = None for schema in aws_accounts: if schema.get('name') == name: aws_account = AwsAccount(self._http_client, schema=schema) break return aws_account
def test_get_schema_by_name(mock_client, mock_schema): aws_account = AwsAccount(None, schema=mock_schema) mock_client.return_value.get_by_name.return_value = aws_account args = ['get-schema', '--name', 'bcttest1'] handler = AwsAccountCliHandler(args, 'fake_api_key', client=mock_client) handler.execute() assert handler._results == json.dumps(aws_account.schema, indent=4)
def get_by_owner_id(self, owner_id): aws_accounts = self.list() aws_account = None for schema in aws_accounts: if schema.get('owner_id') == owner_id: aws_account = AwsAccount(self._http_client, schema=schema) break return aws_account
def test_create_account_from_arg(mock_client, mock_schema): aws_account = AwsAccount(None, schema=mock_schema) mock_client.return_value.create.return_value = aws_account args = ['create', '--name', 'bcttest1'] handler = AwsAccountCliHandler(args, 'fake_api_key', client=mock_client) handler.execute() assert 'Created AWS Account bcttest1' in handler._results
def test_update_account_by_owner_id_from_arg(mock_client, mock_schema): aws_account = AwsAccount(None, schema=mock_schema) mock_client.return_value.update.return_value = aws_account args = [ 'update', '--name', 'bcttest1', '--assume-role-arn', 'arn:aws:iam::619288149268:role/CloudHealth' ] handler = AwsAccountCliHandler(args, 'fake_api_key', client=mock_client) handler.execute() assert 'Updated AWS Account bcttest1' in handler._results
def update(self, schema): aws_account = AwsAccount(self._http_client, schema=schema) aws_account.update_cloudhealth() return aws_account
def get_by_account_id(self, account_id): aws_account = AwsAccount(self._http_client, account_id=account_id) return aws_account
def delete(self, account_id): aws_account = AwsAccount(self._http_client, account_id=account_id) aws_account.delete() return aws_account
def create(self, schema): aws_account = AwsAccount(self._http_client, schema=schema) aws_account.create() return aws_account