Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_release.py
# Copyright (C) 2015-2019 The Software Heritage developers | # Copyright (C) 2015-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 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 | ||||
from datetime import datetime | from datetime import datetime, timezone | ||||
from swh.model.hashutil import hash_to_bytes, hash_to_hex | from swh.model.hashutil import hash_to_bytes, hash_to_hex | ||||
from swh.model.model import ( | from swh.model.model import ObjectType, Person, Release, TimestampWithTimezone | ||||
ObjectType, | |||||
Person, | |||||
Release, | |||||
Timestamp, | |||||
TimestampWithTimezone, | |||||
) | |||||
from swh.web.common.utils import reverse | from swh.web.common.utils import reverse | ||||
from swh.web.tests.data import random_sha1 | from swh.web.tests.data import random_sha1 | ||||
from swh.web.tests.utils import check_api_get_responses, check_http_get_response | from swh.web.tests.utils import check_api_get_responses, check_http_get_response | ||||
def test_api_release(api_client, archive_data, release): | def test_api_release(api_client, archive_data, release): | ||||
url = reverse("api-1-release", url_args={"sha1_git": release}) | url = reverse("api-1-release", url_args={"sha1_git": release}) | ||||
Show All 24 Lines | ): | ||||
target = target["sha1_git"] | target = target["sha1_git"] | ||||
sample_release = Release( | sample_release = Release( | ||||
author=Person( | author=Person( | ||||
email=b"author@company.org", | email=b"author@company.org", | ||||
fullname=b"author <author@company.org>", | fullname=b"author <author@company.org>", | ||||
name=b"author", | name=b"author", | ||||
), | ), | ||||
date=TimestampWithTimezone( | date=TimestampWithTimezone.from_datetime(datetime.now(tz=timezone.utc)), | ||||
timestamp=Timestamp( | |||||
seconds=int(datetime.now().timestamp()), microseconds=0 | |||||
), | |||||
offset=0, | |||||
negative_utc=False, | |||||
), | |||||
message=b"sample release message", | message=b"sample release message", | ||||
name=b"sample release", | name=b"sample release", | ||||
synthetic=False, | synthetic=False, | ||||
target=hash_to_bytes(target), | target=hash_to_bytes(target), | ||||
target_type=target_type, | target_type=target_type, | ||||
) | ) | ||||
archive_data.release_add([sample_release]) | archive_data.release_add([sample_release]) | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |