<commit_before>from contextlib import contextmanager, closing

import pytest
import sqlalchemy
from sqlalchemy.sql.schema import Table as DbTable

from tests.conftest import area_polyfile_string
from tests.inside_worker_test.conftest import slow
from tests.inside_worker_test.declarative_schema import osm_models


@pytest.fixture
def graveyard_polygon(osm_tags):
    return {osm_models.t_osm_polygon: osm_tags}


@pytest.fixture
def graveyard_point(osm_tags):
    return {osm_models.t_osm_point: osm_tags}


@pytest.fixture(
    params=[
        dict(amenity='grave_yard', religion='any value will do, as long as one is present'),
        dict(amenity='grave_yard'),
        dict(landuse='cemetery', religion='any value will do, as long as one is present'),
        dict(landuse='cemetery'),
    ],
    ids=[
        'amenity=grave_yard with religion=*',
        'amenity=grave_yard without religion',
        'landuse=cemetery with religion=*',
        'landuse=cemetery without religion',
    ]
)
def osm_tags(request):
    return request.param


@slow
def test_osmaxx_data_model_processing_does_not_put_amenity_grave_yard_into_table_pow_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_pow_a = DbTable('pow_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_a]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_amenity_grave_yard_into_table_poi_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_poi_a = DbTable('poi_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_a]))) as result:
            assert result.rowcount == 1


@slow
def test_osmaxx_data_model_processing_does_not_put_amenity_grave_yard_into_table_landuse_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_landuse_a = DbTable('landuse_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_landuse_a]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_does_not_put_amenity_grave_yard_into_table_pow_p(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_pow_p = DbTable('pow_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_p]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_amenity_grave_yard_into_table_poi_p(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_poi_p = DbTable('poi_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_p]))) as result:
            assert result.rowcount == 1


@slow
def test_osmaxx_data_model_processing_does_not_put_amenity_grave_yard_point_into_table_pow_p(
        graveyard_point, data_import):
    with data_import(graveyard_point) as engine:
        t_pow_p = DbTable('pow_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_p]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_amenity_grave_yard_point_into_table_poi_p(
        graveyard_point, data_import):
    with data_import(graveyard_point) as engine:
        t_poi_p = DbTable('poi_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_p]))) as result:
            assert result.rowcount == 1


@pytest.fixture()
def data_import(osmaxx_schemas, clean_osm_tables, monkeypatch):
    from tests.inside_worker_test.conftest import cleanup_osmaxx_schemas
    from osmaxx.conversion.converters.converter_gis.bootstrap.bootstrap import BootStrapper<commit_msg>refactoring: rename tests to account for additional fixture parameters #477<commit_after>from contextlib import contextmanager, closing

import pytest
import sqlalchemy
from sqlalchemy.sql.schema import Table as DbTable

from tests.conftest import area_polyfile_string
from tests.inside_worker_test.conftest import slow
from tests.inside_worker_test.declarative_schema import osm_models


@pytest.fixture
def graveyard_polygon(osm_tags):
    return {osm_models.t_osm_polygon: osm_tags}


@pytest.fixture
def graveyard_point(osm_tags):
    return {osm_models.t_osm_point: osm_tags}


@pytest.fixture(
    params=[
        dict(amenity='grave_yard', religion='any value will do, as long as one is present'),
        dict(amenity='grave_yard'),
        dict(landuse='cemetery', religion='any value will do, as long as one is present'),
        dict(landuse='cemetery'),
    ],
    ids=[
        'amenity=grave_yard with religion=*',
        'amenity=grave_yard without religion',
        'landuse=cemetery with religion=*',
        'landuse=cemetery without religion',
    ]
)
def osm_tags(request):
    return request.param


@slow
def test_osmaxx_data_model_processing_does_not_put_burial_ground_into_table_pow_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_pow_a = DbTable('pow_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_a]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_burial_ground_into_table_poi_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_poi_a = DbTable('poi_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_a]))) as result:
            assert result.rowcount == 1


@slow
def test_osmaxx_data_model_processing_does_not_put_burial_ground_into_table_landuse_a(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_landuse_a = DbTable('landuse_a', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_landuse_a]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_does_not_put_burial_ground_into_table_pow_p(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_pow_p = DbTable('pow_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_p]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_burial_ground_into_table_poi_p(
        graveyard_polygon, data_import):
    with data_import(graveyard_polygon) as engine:
        t_poi_p = DbTable('poi_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_p]))) as result:
            assert result.rowcount == 1


@slow
def test_osmaxx_data_model_processing_does_not_put_burial_ground_point_into_table_pow_p(
        graveyard_point, data_import):
    with data_import(graveyard_point) as engine:
        t_pow_p = DbTable('pow_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_pow_p]))) as result:
            assert result.rowcount == 0


@slow
def test_osmaxx_data_model_processing_puts_burial_ground_point_into_table_poi_p(
        graveyard_point, data_import):
    with data_import(graveyard_point) as engine:
        t_poi_p = DbTable('poi_p', osm_models.metadata, schema='osmaxx')
        with closing(engine.execute(sqlalchemy.select([t_poi_p]))) as result:
            assert result.rowcount == 1


@pytest.fixture()
def data_import(osmaxx_schemas, clean_osm_tables, monkeypatch):
    from tests.inside_worker_test.conftest import cleanup_osmaxx_schemas
    from osmaxx.conversion.converters.converter_gis.bootstrap.bootstrap import BootStrapper
{'fraction_non_alphanumeric': 0.08714267724467951, 'fraction_numerical': 0.002140788313814381, 'mean_word_length': 4.600846262341326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3012681', 'n_tokens_mistral': 2788, 'n_tokens_neox': 2673, 'n_words': 478}