Exemplo n.º 1
0
    def test_list_schemas_by_tag(self, *args):
        SchemaFactory(tags=[{
            'key': 'tag_key_1',
            'value': 'tag_value_1'
        }],
                      repository=self.repository_vo,
                      domain_id=self.domain_id)
        schema_vos = SchemaFactory.build_batch(9,
                                               repository=self.repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

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

        schema_svc = SchemaService()
        schemas_vos, total_count = schema_svc.list(params)
        SchemasInfo(schema_vos, total_count)

        self.assertEqual(len(schemas_vos), 1)
        self.assertIsInstance(schemas_vos[0], Schema)
        self.assertEqual(total_count, 1)
Exemplo n.º 2
0
    def test_list_schemas_by_repository(self, *args):
        new_repository_vo = RepositoryFactory(repository_type='local')
        schema_vos = SchemaFactory.build_batch(3,
                                               repository=new_repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

        schema_vos = SchemaFactory.build_batch(7,
                                               repository=self.repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

        params = {
            'repository_id': new_repository_vo.repository_id,
            'domain_id': self.domain_id
        }

        schema_svc = SchemaService()
        schemas_vos, total_count = schema_svc.list(params)
        SchemasInfo(schema_vos, total_count)

        self.assertEqual(len(schemas_vos), 3)
        self.assertIsInstance(schemas_vos[0], Schema)
        self.assertEqual(total_count, 3)
Exemplo n.º 3
0
    def test_list_schemas_by_name(self, *args):
        schema_vos = SchemaFactory.build_batch(10,
                                               repository=self.repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

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

        schema_svc = SchemaService()
        schemas_vos, total_count = schema_svc.list(params)
        SchemasInfo(schema_vos, total_count)

        self.assertEqual(len(schemas_vos), 1)
        self.assertIsInstance(schemas_vos[0], Schema)
        self.assertEqual(total_count, 1)
Exemplo n.º 4
0
    def test_stat_schema_distinct(self, *args):
        schema_vos = SchemaFactory.build_batch(10,
                                               repository=self.repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

        params = {
            'domain_id': self.domain_id,
            'repository_id': self.repository_vo.repository_id,
            'query': {
                'distinct': 'name',
                'page': {
                    'start': 3,
                    'limit': 4
                }
            }
        }

        self.transaction.method = 'stat'
        schema_svc = SchemaService(transaction=self.transaction)
        values = schema_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_schema_distinct')
Exemplo n.º 5
0
    def test_stat_schema(self, *args):
        schema_vos = SchemaFactory.build_batch(10,
                                               repository=self.repository_vo,
                                               domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), schema_vos))

        params = {
            'domain_id': self.domain_id,
            'repository_id': self.repository_vo.repository_id,
            'query': {
                'aggregate': [{
                    'group': {
                        'keys': [{
                            'key': 'name',
                            'name': 'Schema'
                        }],
                        'fields': [{
                            'operator': 'count',
                            'name': 'Count'
                        }]
                    }
                }, {
                    'sort': {
                        'key': 'Count',
                        'desc': True
                    }
                }]
            }
        }

        self.transaction.method = 'stat'
        schema_svc = SchemaService(transaction=self.transaction)
        values = schema_svc.stat(params)
        StatisticsInfo(values)

        print_data(values, 'test_stat_schema')
Exemplo n.º 6
0
 def list(self, params):
     return SchemaFactory.build_batch(10, **params), 10