diff --git a/swh/storage/tests/__init__.py b/swh/storage/tests/__init__.py --- a/swh/storage/tests/__init__.py +++ b/swh/storage/tests/__init__.py @@ -6,50 +6,5 @@ from os import path import swh.storage -from hypothesis.strategies import (binary, composite, sets) - -from swh.model.hashutil import MultiHash - SQL_DIR = path.join(path.dirname(swh.storage.__file__), 'sql') - - -def gen_raw_content(): - """Generate raw content binary. - - """ - return binary(min_size=20, max_size=100) - - -@composite -def gen_contents(draw, *, min_size=0, max_size=100): - """Generate valid and consistent content. - - Context: Test purposes - - Args: - **draw**: Used by hypothesis to generate data - **min_size** (int): Minimal number of elements to generate - (default: 0) - **max_size** (int): Maximal number of elements to generate - (default: 100) - - Returns: - [dict] representing contents. The list's size is between - [min_size:max_size]. - - """ - raw_contents = draw(sets( - gen_raw_content(), - min_size=min_size, max_size=max_size)) - - contents = [] - for raw_content in raw_contents: - contents.append({ - 'data': raw_content, - 'length': len(raw_content), - 'status': 'visible', - **MultiHash.from_data(raw_content).digest() - }) - - return contents diff --git a/swh/storage/tests/__init__.py b/swh/storage/tests/generate_data_test.py copy from swh/storage/tests/__init__.py copy to swh/storage/tests/generate_data_test.py --- a/swh/storage/tests/__init__.py +++ b/swh/storage/tests/generate_data_test.py @@ -1,19 +1,13 @@ -# Copyright (C) 2015-2018 The Software Heritage developers +# Copyright (C) 2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from os import path -import swh.storage - from hypothesis.strategies import (binary, composite, sets) from swh.model.hashutil import MultiHash -SQL_DIR = path.join(path.dirname(swh.storage.__file__), 'sql') - - def gen_raw_content(): """Generate raw content binary. 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 @@ -18,7 +18,7 @@ from swh.storage.tests.storage_testing import StorageTestFixture from swh.storage import HashCollision -from . import gen_contents +from .generate_data_test import gen_contents @pytest.mark.db