diff --git a/swh/storage/tests/__init__.py b/swh/storage/tests/__init__.py index 98728e54..52366435 100644 --- a/swh/storage/tests/__init__.py +++ b/swh/storage/tests/__init__.py @@ -1,56 +1,54 @@ # Copyright (C) 2015-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, lists) 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(lists( gen_raw_content(), min_size=min_size, max_size=max_size)) contents = [] for raw_content in raw_contents: - content = { + contents.append({ 'data': raw_content, 'length': len(raw_content), 'status': 'visible', - } - hashes = MultiHash.from_data(raw_content).digest() - content.update(hashes) - contents.append(content) + **MultiHash.from_data(raw_content).digest() + }) return contents