Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/test_utils.py
# Copyright (C) 2018-2019 The Software Heritage developers | # Copyright (C) 2018-2020 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 unittest.mock import patch | from unittest.mock import patch | ||||
import pytest | import pytest | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | def test_normalize_date_doing_irrelevant_stuff(mock_normalize): | ||||
in swh.model | in swh.model | ||||
""" | """ | ||||
actual_date = utils.normalize_date("2017") | actual_date = utils.normalize_date("2017") | ||||
expected_date = "2017-01-01 00:00:00+00:00" | expected_date = "2017-01-01 00:00:00+00:00" | ||||
assert str(actual_date) == expected_date | assert str(actual_date) == expected_date | ||||
def test_clean_swhid(): | |||||
noisy_swhid = """<swhid>; | |||||
origin=<origin>; | |||||
visit=<visit-swhid>; | |||||
anchor=<anchor-swhid>; path=/ | |||||
""" | |||||
actual_swhid = utils.clean_swhid(noisy_swhid) | |||||
assert actual_swhid == ( | |||||
"<swhid>;origin=<origin>;visit=<visit-swhid>;anchor=<anchor-swhid>;path=/" | |||||
) |