<commit_before># pylint: disable=C0111
import os
import tempfile
from collections import Mapping
from datetime import timedelta

import pytest

from osmaxx.utils.frozendict import frozendict

test_data_dir = os.path.join(os.path.dirname(__file__), 'test_data')

postgres_container_userland_port = 65432  # required for travis, so using it everywhere


def pytest_configure():
    from django.conf import settings
    import environ

    settings.configure(
        ROOT_DIR=environ.Path(__file__) - 1,
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.contrib.gis.db.backends.postgis',
                'NAME': 'postgres',
                'USER': 'postgres',
                'PASSWORD': '<PASSWORD>',
                'PORT': '54321',
                'HOST': '127.0.0.1',
            }
        },
        SITE_ID=1,
        SECRET_KEY='not very secret in tests',
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        MEDIA_URL='/media/',
        MEDIA_ROOT=tempfile.mkdtemp(),
        ROOT_URLCONF='tests.urls',
        TEMPLATE_LOADERS=(
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        ),
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'OPTIONS': {
                    'context_processors': [
                        'django.contrib.auth.context_processors.auth',
                        'django.template.context_processors.debug',
                        'django.template.context_processors.i18n',
                        'django.template.context_processors.media',
                        'django.template.context_processors.static',
                        'django.template.context_processors.tz',
                        'django.contrib.messages.context_processors.messages',
                        'django.template.context_processors.request',
                    ],
                    'loaders': [
                        'django.template.loaders.filesystem.Loader',
                        'django.template.loaders.app_directories.Loader',
                    ]
                },
            },
        ],
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'osmaxx.job_progress.middleware.ExportUpdaterMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.messages',
            'django.contrib.staticfiles',
            'django.contrib.gis',

            'rest_framework',
            'rest_framework_gis',
            'rest_framework.authtoken',
            'crispy_forms',
            'stored_messages',

            'tests',

            # version app
            'osmaxx.version',

            # conversion service apps
            'osmaxx.clipping_area',
            'osmaxx.conversion',

            # web_frontend apps
            'osmaxx.core',
            'osmaxx.excerptexport',
            'osmaxx.job_progress',
            'osmaxx.profile',

            # special model for testing only
            'tests.utilities.test_models',
        ),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.SHA1PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
            'django.contrib.auth.hashers.BCryptPasswordHasher',
            'django.contrib.auth.hashers.MD5PasswordHasher',
            'django.contrib.auth.hashers.CryptPasswordHasher',
        ),
        RQ_QUEUE_NAMES=['default'],
        RQ_QUEUES={
            'default': {
                'HOST': 'localhost',
                'PORT': 6379,
                'DB': 0,
                'PASSWORD': '',
                'DEFAULT_TIMEOUT': 3600,
            },
        },
        JWT_AUTH={
            'JWT_ENCODE_HANDLER': 'rest_framework_jwt.utils.jwt_encode_handler',
            'JWT_DECODE_HANDLER': 'rest_framework_jwt.utils.jwt_decode_handler',
            'JWT_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_payload_handler',
            'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
            'JWT_RESPONSE_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_response_payload_handler',

            'JWT_ALGORITHM': 'HS256',
            'JWT_VERIFY': True,
            'JWT_VERIFY_EXPIRATION': True,
            'JWT_LEEWAY': 0,
            'JWT_EXPIRATION_DELTA': timedelta(seconds=300),
            'JWT_AUDIENCE': None,
            'JWT_ISSUER': None,

            'JWT_ALLOW_REFRESH': False,
            'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=7),

            'JWT_AUTH_HEADER_PREFIX': 'JWT',
        },
        OSMAXX_CONVERSION_SERVICE={
            'PBF_PLANET_FILE_PATH': os.path.join(test_data_dir, 'osm', 'monaco-latest.osm.pbf'),
        },
        _OSMAXX_POLYFILE_LOCATION=os.path.join(test_data_dir, 'polyfiles'),
        OSMAXX_TEST_SETTINGS={
            'CONVERSION_SERVICE_URL': 'http://localhost:8901/api/',
            'CONVERSION_SERVICE_USERNAME': 'dev',
            'CONVERSION_SERVICE_PASSWORD': '<PASSWORD>',
        },
        OSMAXX={
            'download_file_name': '%(excerpt_name)s-%(date)s.%(content_type)s.%(file_extension)s',
            'EXTRACTION_PROCESSING_TIMEOUT_TIMEDELTA': timedelta(hours=48),
            # The email adress of this user will be used to generate the mailto link for users
            # to request access to osmaxx (access_denied page)
            'CONVERSION_SERVICE_URL': 'http://localhost:8901/api/',
            'CONVERSION_SERVICE_USERNAME': 'dev',
            'CONVERSION_SERVICE_PASSWORD': '<PASSWORD>',
            'EXCLUSIVE_USER_GROUP': 'dev',
            'ACCOUNT_MANAGER_EMAIL': '<EMAIL>',
        },
        OSMAXX_FRONTEND_USER_GROUP='osmaxx_frontend_users',
        REGISTRATION_OPEN=True,
        REGISTRATION_VERIFICATION_TIMEOUT_DAYS=2,
        CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
                'LOCATION': ''
            }
        },
        MIGRATION_MODULES={
            'sites': 'osmaxx.contrib.sites.migrations',
            'auth': 'osmaxx.contrib.auth.migrations',
            'stored_messages': 'osmaxx.third_party_apps.stored_messages.migrations',
        }
    )


# if any global fixtures are needed, add them below

@pytest.yield_fixture
def requests_mock():
    import requests_mock<commit_msg>place comment directly above the setting it applies to<commit_after># pylint: disable=C0111
import os
import tempfile
from collections import Mapping
from datetime import timedelta

import pytest

from osmaxx.utils.frozendict import frozendict

test_data_dir = os.path.join(os.path.dirname(__file__), 'test_data')

postgres_container_userland_port = 65432  # required for travis, so using it everywhere


def pytest_configure():
    from django.conf import settings
    import environ

    settings.configure(
        ROOT_DIR=environ.Path(__file__) - 1,
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.contrib.gis.db.backends.postgis',
                'NAME': 'postgres',
                'USER': 'postgres',
                'PASSWORD': '<PASSWORD>',
                'PORT': '54321',
                'HOST': '127.0.0.1',
            }
        },
        SITE_ID=1,
        SECRET_KEY='not very secret in tests',
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        MEDIA_URL='/media/',
        MEDIA_ROOT=tempfile.mkdtemp(),
        ROOT_URLCONF='tests.urls',
        TEMPLATE_LOADERS=(
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        ),
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'OPTIONS': {
                    'context_processors': [
                        'django.contrib.auth.context_processors.auth',
                        'django.template.context_processors.debug',
                        'django.template.context_processors.i18n',
                        'django.template.context_processors.media',
                        'django.template.context_processors.static',
                        'django.template.context_processors.tz',
                        'django.contrib.messages.context_processors.messages',
                        'django.template.context_processors.request',
                    ],
                    'loaders': [
                        'django.template.loaders.filesystem.Loader',
                        'django.template.loaders.app_directories.Loader',
                    ]
                },
            },
        ],
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'osmaxx.job_progress.middleware.ExportUpdaterMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.messages',
            'django.contrib.staticfiles',
            'django.contrib.gis',

            'rest_framework',
            'rest_framework_gis',
            'rest_framework.authtoken',
            'crispy_forms',
            'stored_messages',

            'tests',

            # version app
            'osmaxx.version',

            # conversion service apps
            'osmaxx.clipping_area',
            'osmaxx.conversion',

            # web_frontend apps
            'osmaxx.core',
            'osmaxx.excerptexport',
            'osmaxx.job_progress',
            'osmaxx.profile',

            # special model for testing only
            'tests.utilities.test_models',
        ),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.SHA1PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
            'django.contrib.auth.hashers.BCryptPasswordHasher',
            'django.contrib.auth.hashers.MD5PasswordHasher',
            'django.contrib.auth.hashers.CryptPasswordHasher',
        ),
        RQ_QUEUE_NAMES=['default'],
        RQ_QUEUES={
            'default': {
                'HOST': 'localhost',
                'PORT': 6379,
                'DB': 0,
                'PASSWORD': '',
                'DEFAULT_TIMEOUT': 3600,
            },
        },
        JWT_AUTH={
            'JWT_ENCODE_HANDLER': 'rest_framework_jwt.utils.jwt_encode_handler',
            'JWT_DECODE_HANDLER': 'rest_framework_jwt.utils.jwt_decode_handler',
            'JWT_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_payload_handler',
            'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
            'JWT_RESPONSE_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_response_payload_handler',

            'JWT_ALGORITHM': 'HS256',
            'JWT_VERIFY': True,
            'JWT_VERIFY_EXPIRATION': True,
            'JWT_LEEWAY': 0,
            'JWT_EXPIRATION_DELTA': timedelta(seconds=300),
            'JWT_AUDIENCE': None,
            'JWT_ISSUER': None,

            'JWT_ALLOW_REFRESH': False,
            'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=7),

            'JWT_AUTH_HEADER_PREFIX': 'JWT',
        },
        OSMAXX_CONVERSION_SERVICE={
            'PBF_PLANET_FILE_PATH': os.path.join(test_data_dir, 'osm', 'monaco-latest.osm.pbf'),
        },
        _OSMAXX_POLYFILE_LOCATION=os.path.join(test_data_dir, 'polyfiles'),
        OSMAXX_TEST_SETTINGS={
            'CONVERSION_SERVICE_URL': 'http://localhost:8901/api/',
            'CONVERSION_SERVICE_USERNAME': 'dev',
            'CONVERSION_SERVICE_PASSWORD': '<PASSWORD>',
        },
        OSMAXX={
            'download_file_name': '%(excerpt_name)s-%(date)s.%(content_type)s.%(file_extension)s',
            'EXTRACTION_PROCESSING_TIMEOUT_TIMEDELTA': timedelta(hours=48),
            'CONVERSION_SERVICE_URL': 'http://localhost:8901/api/',
            'CONVERSION_SERVICE_USERNAME': 'dev',
            'CONVERSION_SERVICE_PASSWORD': '<PASSWORD>',
            'EXCLUSIVE_USER_GROUP': 'dev',
            # The email adress of this user will be used to generate the mailto link for users
            # to request access to osmaxx (access_denied page)
            'ACCOUNT_MANAGER_EMAIL': '<EMAIL>',
        },
        OSMAXX_FRONTEND_USER_GROUP='osmaxx_frontend_users',
        REGISTRATION_OPEN=True,
        REGISTRATION_VERIFICATION_TIMEOUT_DAYS=2,
        CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
                'LOCATION': ''
            }
        },
        MIGRATION_MODULES={
            'sites': 'osmaxx.contrib.sites.migrations',
            'auth': 'osmaxx.contrib.auth.migrations',
            'stored_messages': 'osmaxx.third_party_apps.stored_messages.migrations',
        }
    )


# if any global fixtures are needed, add them below

@pytest.yield_fixture
def requests_mock():
    import requests_mock
{'fraction_non_alphanumeric': 0.10955961331901182, 'fraction_numerical': 0.008736126029359113, 'mean_word_length': 1.9482795017943846, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3171804', 'n_tokens_mistral': 4327, 'n_tokens_neox': 4162, 'n_words': 531}