Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/conftest.py
Show First 20 Lines • Show All 515 Lines • ▼ Show 20 Lines | def releases(tests_data): | ||||
"""Fixture returning random releases ingested into the test archive. | """Fixture returning random releases ingested into the test archive. | ||||
""" | """ | ||||
return random.choices( | return random.choices( | ||||
_known_swh_objects(tests_data, "releases"), k=random.randint(2, 8) | _known_swh_objects(tests_data, "releases"), k=random.randint(2, 8) | ||||
) | ) | ||||
@pytest.fixture(scope="function") | @pytest.fixture(scope="function") | ||||
def snapshot(tests_data): | |||||
"""Fixture returning a random snapshot ingested into the test archive. | |||||
""" | |||||
return random.choice(_known_swh_objects(tests_data, "snapshots")) | |||||
@pytest.fixture(scope="function") | |||||
def origin(tests_data): | def origin(tests_data): | ||||
"""Fixturee returning a random origin ingested into the test archive. | """Fixture returning a random origin ingested into the test archive. | ||||
""" | """ | ||||
return random.choice(_known_swh_objects(tests_data, "origins")) | return random.choice(_known_swh_objects(tests_data, "origins")) | ||||
@pytest.fixture(scope="function") | @pytest.fixture(scope="function") | ||||
def origin_with_multiple_visits(tests_data): | def origin_with_multiple_visits(tests_data): | ||||
"""Fixture returning a random origin with multiple visits ingested | """Fixture returning a random origin with multiple visits ingested | ||||
into the test archive. | into the test archive. | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
@pytest.fixture(scope="function") | @pytest.fixture(scope="function") | ||||
def revision_swhid(tests_data): | def revision_swhid(tests_data): | ||||
"""Fixture returning a qualified SWHID for a random revision object | """Fixture returning a qualified SWHID for a random revision object | ||||
ingested into the test archive. | ingested into the test archive. | ||||
""" | """ | ||||
return _object_type_swhid(tests_data, ObjectType.REVISION) | return _object_type_swhid(tests_data, ObjectType.REVISION) | ||||
@pytest.fixture(scope="function") | |||||
def snapshot_swhid(): | |||||
"""Fixture returning a qualified SWHID for a snapshot object | |||||
ingested into the test archive. | |||||
""" | |||||
return _object_type_swhid(tests_data, ObjectType.SNAPSHOT) | |||||
# 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(scope="function") | @pytest.fixture(scope="function") | ||||
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(scope="function") | @pytest.fixture(scope="function") | ||||
▲ Show 20 Lines • Show All 368 Lines • Show Last 20 Lines |