diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,3 +1,3 @@ swh.core[db,http] >= 0.0.65 -swh.model >= 0.0.41 +swh.model >= 0.0.50 swh.objstorage >= 0.0.17 diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,3 +2,8 @@ pytest pytest-postgresql >= 2.1.0 sqlalchemy-stubs +# pytz is in fact a dep of swh.model[testing] and should not be necessary, but +# the dep on swh.model in the main requirements-swh.txt file shadows this one +# adding the [testing] extra. +swh.model[testing] >= 0.0.50 +pytz diff --git a/swh/storage/tests/conftest.py b/swh/storage/tests/conftest.py --- a/swh/storage/tests/conftest.py +++ b/swh/storage/tests/conftest.py @@ -10,14 +10,15 @@ from pytest_postgresql.janitor import DatabaseJanitor, psycopg2 from os import path, environ -from hypothesis import settings, strategies +from hypothesis import settings from typing import Dict import swh.storage -from swh.model.hypothesis_strategies import origins, contents from swh.core.utils import numfile_sortkey as sortkey +from swh.model.tests.generate_testdata import gen_contents, gen_origins + SQL_DIR = path.join(path.dirname(swh.storage.__file__), 'sql') @@ -54,30 +55,16 @@ return storage -def gen_origins(n=20): - return strategies.lists( - origins().map(lambda x: x.to_dict()), - unique_by=lambda x: x['url'], - min_size=n, max_size=n).example() - - -def gen_contents(n=20): - return strategies.lists( - contents().map(lambda x: x.to_dict()), - unique_by=lambda x: (x['sha1'], x['sha1_git']), - min_size=n, max_size=n).example() - - @pytest.fixture def swh_contents(swh_storage): - contents = gen_contents() + contents = gen_contents(n=20) swh_storage.content_add(contents) return contents @pytest.fixture def swh_origins(swh_storage): - origins = gen_origins() + origins = gen_origins(n=100) swh_storage.origin_add(origins) return origins diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -3235,10 +3235,10 @@ actual_origins = list( swh_storage.origin_get_range(origin_from=1, - origin_count=21)) - assert len(actual_origins) == 20 + origin_count=101)) + assert len(actual_origins) == 100 assert actual_origins[0]['id'] == 1 - assert actual_origins[-1]['id'] == 20 + assert actual_origins[-1]['id'] == 100 actual_origins = list( swh_storage.origin_get_range(origin_from=11, @@ -3253,11 +3253,11 @@ assert actual_origins[-1]['id'] == 20 actual_origins = list( - swh_storage.origin_get_range(origin_from=11, + swh_storage.origin_get_range(origin_from=91, origin_count=11)) assert len(actual_origins) == 10 - assert actual_origins[0]['id'] == 11 - assert actual_origins[-1]['id'] == 20 + assert actual_origins[0]['id'] == 91 + assert actual_origins[-1]['id'] == 100 def test_origin_count(self, swh_storage): new_origins = [