Beispiel #1
0
    def test_list_user_configs_by_name(self, *args):
        user_config_vos = UserConfigFactory.build_batch(10, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_config_vos))

        params = {
            'name': user_config_vos[0].name,
            'domain_id': self.domain_id
        }

        self.transaction.method = 'list'
        user_config_svc = UserConfigService(transaction=self.transaction)
        user_config_vos, total_count = user_config_svc.list(params.copy())
        UserConfigsInfo(user_config_vos, total_count)

        self.assertEqual(len(user_config_vos), 1)
        self.assertIsInstance(user_config_vos[0], UserConfig)
        self.assertEqual(total_count, 1)
Beispiel #2
0
    def test_list_user_configs_by_tag(self, *args):
        UserConfigFactory(tags=[{'key': 'tag_key_1', 'value': 'tag_value_1'}], domain_id=self.domain_id)
        user_config_vos = UserConfigFactory.build_batch(9, domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), user_config_vos))

        params = {
            'query': {
                'filter': [{
                    'k': 'tags.tag_key_1',
                    'v': 'tag_value_1',
                    'o': 'eq'
                }]
            },
            'domain_id': self.domain_id
        }

        self.transaction.method = 'list'
        user_config_svc = UserConfigService(transaction=self.transaction)
        user_config_vos, total_count = user_config_svc.list(params.copy())
        UserConfigsInfo(user_config_vos, total_count)

        self.assertEqual(len(user_config_vos), 1)
        self.assertIsInstance(user_config_vos[0], UserConfig)
        self.assertEqual(total_count, 1)