コード例 #1
0
def _get_check(import_def, model_def, check_type, check_props):
    table = f"{import_def['target']}_new"
    if check_type == 'count':
        if 'count_minimum' in check_props:
            count_method = assert_count_minimum(check_props['count_minimum'])
        else:
            raise NotImplementedError
        return [('count', f"select count(*) from {table}", count_method)]
    elif check_type == 'geometrie':
        model_repr = get_model_repr(model_def)
        geo_fields = [
            field for field in model_repr
            if isinstance(field, GeoFieldRepresentation)
        ]

        collect_checks = []
        for field in geo_fields:
            if not field.allow_null:
                collect_checks.append((
                    f'filled_geometrie_{field.field_name}',
                    f"select count(*) from {table} where {field.field_name} is null",
                    assert_count_zero()))
            collect_checks.append((
                f'valid_geometrie_{field.field_name}',
                f"select count(*) from {table} where ST_IsValid({field.field_name}) = false",
                assert_count_zero()))
            collect_checks.append(
                (f'geometrie_type_{field.field_name}',
                 f"select count(*) from {table} where "
                 f"ST_GeometryType({field.field_name}) <> '{field.psql_type}'",
                 assert_count_zero()))
        return collect_checks
    else:
        raise NotImplementedError
コード例 #2
0
#!/usr/bin/env python
from utils.check_imported_data import main, assert_count_minimum, assert_count_zero

sql_checks = [
    ('count', "select count(*) from overlastgebieden_new", assert_count_minimum(110)),
    ('columns', """
select column_name from information_schema.columns where                                                                  
table_schema = 'public' and table_name = 'overlastgebieden_new'
    """, lambda x: x == [('ogc_fid',), ('wkb_geometry',), ('oov_naam',), ('type',), ('url',)]),
    ('geometrie', """
select count(*) from overlastgebieden_new where
wkb_geometry is null or ST_IsValid(wkb_geometry) = false or ST_GeometryType(wkb_geometry) <> 'ST_Polygon'
    """,
     assert_count_zero()),
]

if __name__ == '__main__':
    main(sql_checks)
コード例 #3
0
#!/usr/bin/env python
from utils.check_imported_data import main, assert_count_zero, assert_count_minimum

sql_checks = [
    ('count', "select count(*) from parkeerzones_new",
     assert_count_minimum(100)),
    ('count_uitz', "select count(*) from parkeerzones_uitz_new",
     assert_count_minimum(60)),
    ('geometrie', """
select count(*) from parkeerzones_new where
wkb_geometry is null or ST_GeometryType(wkb_geometry) <> 'ST_Polygon'
    """, assert_count_zero()),
    ('geometrie', """
    select count(*) from parkeerzones_uitz_new where
    wkb_geometry is null or ST_GeometryType(wkb_geometry) <> 'ST_Polygon'
        """, assert_count_zero()),
    #    ('columns', """
    #select column_name from information_schema.columns where
    #table_schema = 'public' and table_name = 'hoofdroutes_new'
    #    """, lambda x: x == [("ogc_fid",), ("wkb_geometry",), ("id",), ("name",), ("route",), ("type",)]),
]

if __name__ == '__main__':
    main(sql_checks)