Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_converters.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2021 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 Affero General Public License version 3, or any later version | # License: GNU Affero 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 | ||||
import datetime | import datetime | ||||
import hashlib | |||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
ObjectType, | ObjectType, | ||||
Person, | Person, | ||||
Release, | Release, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | def test_from_swh_empty(): | ||||
assert {} == converters.from_swh({}) | assert {} == converters.from_swh({}) | ||||
def test_from_swh_none(): | def test_from_swh_none(): | ||||
assert converters.from_swh(None) is None | assert converters.from_swh(None) is None | ||||
def test_from_origin(): | def test_from_origin(): | ||||
origin_url = "rsync://ftp.gnu.org/gnu/octave" | |||||
origin_input = { | origin_input = { | ||||
"id": 9, | "id": hashlib.sha1(origin_url.encode("utf-8")).digest(), | ||||
"type": "ftp", | "url": origin_url, | ||||
"url": "rsync://ftp.gnu.org/gnu/octave", | |||||
} | } | ||||
expected_origin = { | expected_origin = { | ||||
"id": 9, | "url": origin_url, | ||||
"type": "ftp", | |||||
"url": "rsync://ftp.gnu.org/gnu/octave", | |||||
} | } | ||||
actual_origin = converters.from_origin(origin_input) | actual_origin = converters.from_origin(origin_input) | ||||
assert actual_origin == expected_origin | assert actual_origin == expected_origin | ||||
def test_from_origin_visit(): | def test_from_origin_visit(): | ||||
▲ Show 20 Lines • Show All 579 Lines • Show Last 20 Lines |