Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_writer.py
- This file was added.
# Copyright (C) 2020 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 swh.storage.writer import to_one_dict, to_dict | |||||
from swh.model.model import Content, Snapshot | |||||
def test_to_one_dict(sample_data): | |||||
content = sample_data['content'][0] | |||||
assert to_one_dict({'a': 1}) == {'a': 1} | |||||
assert to_one_dict(Content.from_dict(content)) == content | |||||
def test_to_dict(sample_data): | |||||
cont = sample_data['content'][0] | |||||
cont2 = sample_data['content'][1] | |||||
snap = sample_data['snapshot'][0] | |||||
assert list(to_dict([{'a': 1}])) == [{'a': 1}] | |||||
inputs = [Content.from_dict(cont), cont2, Snapshot.from_dict(snap)] | |||||
assert list(to_dict(inputs)) == [cont, cont2, snap] |