import logging import os from logging import getLogger import pytest from db_schema.postgres import connection LOG = getLogger(__name__) @pytest.fixture(scope='session') def db(): pg = connection.get_session( host=os.getenv('PG_HOST', '0.0.0.0'), port=int(os.getenv('PG_PORT', '5432')), db=os.getenv('PG_DB', 'slz'), user=os.getenv('PG_USER', 'admin'), password=os.getenv('PG_PASSWORD', 'admin'), engine_params={'echo': True} ) yield pg @pytest.fixture(scope='session', autouse=True) def disable_logging(): logging.disable(logging.ERROR) @pytest.fixture def es_reindex_deferred_response(): return {'task': 'pZ_4vs8ZRZqt7L9uC1Gy2w:22903'} @pytest.fixture def es_reindex_response(): return { 'took': 639, 'timed_out': False, 'total': 5, 'updated': 0, 'created': 5, 'deleted': 0, 'batches': 1, 'noops': 0, 'version_conflicts': 2, 'retries': { 'bulk': 0, 'search': 0 }, 'throttled_millis': 0, 'requests_per_second': 1, 'throttled_until_millis': 0, 'failures': [] } @pytest.fixture # pylint: disable=redefined-outer-name def es_task_response(es_reindex_response): return { 'completed': True, 'task': { 'node': 'pZ_4vs8ZRZqt7L9uC1Gy2w', 'id': 22903, 'type': 'transport', 'action': 'indices:data/write/reindex', 'status': { 'total': 1, 'updated': 0, 'created': 1, 'deleted': 0, 'batches': 1, 'version_conflicts': 0, 'noops': 0, 'retries': { 'bulk': 0, 'search': 0 }, 'throttled_millis': 0, 'requests_per_second': -1, 'throttled_until_millis': 0 }, 'description': 'reindex from [linkfire-link] to [linkfire-link_2021-05-06t18-54-31.174692z]', 'start_time_in_millis': 1620327271, 'running_time_in_nanos': 189810046, 'cancellable': True }, 'response': es_reindex_response }