Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/conftest.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import glob | import glob | ||||
import pytest | import pytest | ||||
from pytest_postgresql import factories | from pytest_postgresql import factories | ||||
from pytest_postgresql.janitor import DatabaseJanitor, psycopg2 | from pytest_postgresql.janitor import DatabaseJanitor, psycopg2 | ||||
from os import path, environ | from os import path, environ | ||||
from hypothesis import strategies | from hypothesis import settings, strategies | ||||
from typing import Dict | from typing import Dict | ||||
import swh.storage | import swh.storage | ||||
from swh.model.hypothesis_strategies import origins, contents | from swh.model.hypothesis_strategies import origins, contents | ||||
from swh.core.utils import numfile_sortkey as sortkey | from swh.core.utils import numfile_sortkey as sortkey | ||||
SQL_DIR = path.join(path.dirname(swh.storage.__file__), 'sql') | SQL_DIR = path.join(path.dirname(swh.storage.__file__), 'sql') | ||||
environ['LC_ALL'] = 'C.UTF-8' | environ['LC_ALL'] = 'C.UTF-8' | ||||
DUMP_FILES = path.join(SQL_DIR, '*.sql') | DUMP_FILES = path.join(SQL_DIR, '*.sql') | ||||
# define tests profile. Full documentation is at: | |||||
# https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles | |||||
settings.register_profile("fast", max_examples=5, deadline=5000) | |||||
settings.register_profile("slow", max_examples=20, deadline=5000) | |||||
@pytest.fixture | @pytest.fixture | ||||
def swh_storage(postgresql_proc, swh_storage_postgresql): | def swh_storage(postgresql_proc, swh_storage_postgresql): | ||||
storage_config = { | storage_config = { | ||||
'cls': 'local', | 'cls': 'local', | ||||
'args': { | 'args': { | ||||
'db': 'postgresql://{user}@{host}:{port}/{dbname}'.format( | 'db': 'postgresql://{user}@{host}:{port}/{dbname}'.format( | ||||
host=postgresql_proc.host, | host=postgresql_proc.host, | ||||
▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines |