Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/conftest.py
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
# Fixture to get API request factory from Django REST Framework | # Fixture to get API request factory from Django REST Framework | ||||
@pytest.fixture(scope='module') | @pytest.fixture(scope='module') | ||||
def api_request_factory(): | def api_request_factory(): | ||||
return APIRequestFactory() | return APIRequestFactory() | ||||
# Initialize tests data | # Initialize tests data | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(scope='session', autouse=True) | ||||
def tests_data(): | def tests_data(): | ||||
data = get_tests_data(reset=True) | data = get_tests_data(reset=True) | ||||
# Update swh-web configuration to use the in-memory storages | # Update swh-web configuration to use the in-memory storages | ||||
# instantiated in the tests.data module | # instantiated in the tests.data module | ||||
override_storages(data['storage'], data['idx_storage'], data['search']) | override_storages(data['storage'], data['idx_storage'], data['search']) | ||||
return data | return data | ||||
# Fixture to manipulate data from a sample archive used in the tests | # Fixture to manipulate data from a sample archive used in the tests | ||||
@pytest.fixture | @pytest.fixture(scope='session') | ||||
def archive_data(tests_data): | def archive_data(tests_data): | ||||
return _ArchiveData(tests_data) | return _ArchiveData(tests_data) | ||||
# Fixture to manipulate indexer data from a sample archive used in the tests | # Fixture to manipulate indexer data from a sample archive used in the tests | ||||
@pytest.fixture | @pytest.fixture(scope='session') | ||||
def indexer_data(tests_data): | def indexer_data(tests_data): | ||||
return _IndexerData(tests_data) | return _IndexerData(tests_data) | ||||
# Custom data directory for requests_mock | # Custom data directory for requests_mock | ||||
@pytest.fixture | @pytest.fixture | ||||
def datadir(): | def datadir(): | ||||
return os.path.join(os.path.abspath(os.path.dirname(__file__)), | return os.path.join(os.path.abspath(os.path.dirname(__file__)), | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |