Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_origin.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-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 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 | ||||
import random | import random | ||||
import re | import re | ||||
import string | import string | ||||
import textwrap | import textwrap | ||||
from django.utils.html import escape | from django.utils.html import escape | ||||
from hypothesis import given | from hypothesis import given | ||||
▲ Show 20 Lines • Show All 653 Lines • ▼ Show 20 Lines | snapshot = Snapshot( | ||||
branches={ | branches={ | ||||
branch_name.encode(): SnapshotBranch( | branch_name.encode(): SnapshotBranch( | ||||
target=hash_to_bytes(unknown_revision), target_type=TargetType.REVISION, | target=hash_to_bytes(unknown_revision), target_type=TargetType.REVISION, | ||||
) | ) | ||||
} | } | ||||
) | ) | ||||
new_origin = archive_data.origin_add([new_origin])[0] | new_origin = archive_data.origin_add([new_origin])[0] | ||||
archive_data.snapshot_add([snapshot]) | archive_data.snapshot_add([snapshot]) | ||||
visit = archive_data.origin_visit_add(new_origin["url"], datetime.now(), type="git") | visit = archive_data.origin_visit_add( | ||||
new_origin["url"], datetime.now(tz=timezone.utc), type="git" | |||||
) | |||||
archive_data.origin_visit_update( | archive_data.origin_visit_update( | ||||
new_origin["url"], visit.visit, status="full", snapshot=snapshot.id | new_origin["url"], visit.visit, status="full", snapshot=snapshot.id | ||||
) | ) | ||||
url = reverse( | url = reverse( | ||||
"browse-origin-directory", | "browse-origin-directory", | ||||
query_params={"origin_url": new_origin["url"], "branch": branch_name}, | query_params={"origin_url": new_origin["url"], "branch": branch_name}, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |