def test_list_service_accounts_by_tag(self, *args): ServiceAccountFactory(tags=[{ 'key': 'tag_key_1', 'value': 'tag_value_1' }], domain_id=self.domain_id) service_account_vos = ServiceAccountFactory.build_batch( 9, project=None, domain_id=self.domain_id) list(map(lambda vo: vo.save(), service_account_vos)) params = { 'query': { 'filter': [{ 'k': 'tags.tag_key_1', 'v': 'tag_value_1', 'o': 'eq' }] }, 'domain_id': self.domain_id } service_account_svc = ServiceAccountService() service_accounts_vos, total_count = service_account_svc.list(params) ServiceAccountsInfo(service_account_vos, total_count) self.assertEqual(len(service_accounts_vos), 1) self.assertIsInstance(service_accounts_vos[0], ServiceAccount) self.assertEqual(total_count, 1)
def test_list_service_accounts_by_name(self, *args): service_account_vos = ServiceAccountFactory.build_batch( 10, project=None, domain_id=self.domain_id) list(map(lambda vo: vo.save(), service_account_vos)) params = { 'name': service_account_vos[0].name, 'domain_id': self.domain_id } service_account_svc = ServiceAccountService() service_accounts_vos, total_count = service_account_svc.list(params) ServiceAccountsInfo(service_account_vos, total_count) self.assertEqual(len(service_accounts_vos), 1) self.assertIsInstance(service_accounts_vos[0], ServiceAccount) self.assertEqual(total_count, 1)