Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_generate_testdata.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from .generate_testdata import gen_contents, gen_origins, ORIGINS | from .generate_testdata import gen_contents, gen_origins, ORIGINS | ||||
from swh.model.model import Origin, Content | from swh.model.model import Origin, BaseContent | ||||
def test_gen_origins_empty(): | def test_gen_origins_empty(): | ||||
origins = gen_origins(0) | origins = gen_origins(0) | ||||
assert not origins | assert not origins | ||||
def test_gen_origins_one(): | def test_gen_origins_one(): | ||||
Show All 21 Lines | |||||
def test_gen_contents_empty(): | def test_gen_contents_empty(): | ||||
contents = gen_contents(0) | contents = gen_contents(0) | ||||
assert not contents | assert not contents | ||||
def test_gen_contents_one(): | def test_gen_contents_one(): | ||||
contents = gen_contents(1) | contents = gen_contents(1) | ||||
assert len(contents) == 1 | assert len(contents) == 1 | ||||
assert [Content.from_dict(d) for d in contents] | assert [BaseContent.from_dict(d) for d in contents] | ||||
def test_gen_contents_default(): | def test_gen_contents_default(): | ||||
contents = gen_contents() | contents = gen_contents() | ||||
assert len(contents) == 20 | assert len(contents) == 20 | ||||
models = {Content.from_dict(d) for d in contents} | models = {BaseContent.from_dict(d) for d in contents} | ||||
# ensure we did not generate the same content twice | # ensure we did not generate the same content twice | ||||
assert len(contents) == len(models) | assert len(contents) == len(models) |