Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/data.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 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 swh.model.hashutil import hash_to_bytes | |||||
from swh.model.model import ObjectType, Release, Revision, RevisionType | from swh.model.model import ObjectType, Release, Revision, RevisionType | ||||
from swh.model.tests import swh_model_data | from swh.model.tests import swh_model_data | ||||
def populate_search_data(search): | def populate_search_data(search): | ||||
search.origin_update({"url": origin.url} for origin in get_origins()) | search.origin_update({"url": origin.url} for origin in get_origins()) | ||||
Show All 24 Lines | |||||
def get_releases_with_target(): | def get_releases_with_target(): | ||||
""" | """ | ||||
GraphQL will not return a target object unless the target id | GraphQL will not return a target object unless the target id | ||||
is present in the DB. | is present in the DB. | ||||
Return release objects with real targets instead of dummy | Return release objects with real targets instead of dummy | ||||
targets in swh.model.tests.swh_model_data | targets in swh.model.tests.swh_model_data | ||||
""" | """ | ||||
with_revision = Release( | with_revision = Release( | ||||
id=hash_to_bytes("9129dc4e14acd0e51ca3bcd6b80f4577d281fd25"), | |||||
name=b"v0.0.1", | name=b"v0.0.1", | ||||
target_type=ObjectType.REVISION, | target_type=ObjectType.REVISION, | ||||
target=get_revisions()[0].id, | target=get_revisions()[0].id, | ||||
message=b"foo", | message=b"foo", | ||||
synthetic=False, | synthetic=False, | ||||
) | ) | ||||
with_release = Release( | with_release = Release( | ||||
id=hash_to_bytes("6429dc4e14acd0e51ca3bcd6b80f4577d281fd32"), | |||||
name=b"v0.0.1", | name=b"v0.0.1", | ||||
target_type=ObjectType.RELEASE, | target_type=ObjectType.RELEASE, | ||||
target=get_releases()[0].id, | target=get_releases()[0].id, | ||||
message=b"foo", | message=b"foo", | ||||
synthetic=False, | synthetic=False, | ||||
) | ) | ||||
with_directory = Release( | with_directory = Release( | ||||
id=hash_to_bytes("3129dc4e14acd0e51ca3bcd6b80f4577d281fd42"), | |||||
name=b"v0.0.1", | name=b"v0.0.1", | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
target=get_directories()[0].id, | target=get_directories()[0].id, | ||||
message=b"foo", | message=b"foo", | ||||
synthetic=False, | synthetic=False, | ||||
) | ) | ||||
with_content = Release( | with_content = Release( | ||||
id=hash_to_bytes("7589dc4e14acd0e51ca3bcd6b80f4577d281fd34"), | |||||
name=b"v0.0.1", | name=b"v0.0.1", | ||||
target_type=ObjectType.CONTENT, | target_type=ObjectType.CONTENT, | ||||
target=get_contents()[0].sha1_git, | target=get_contents()[0].sha1_git, | ||||
message=b"foo", | message=b"foo", | ||||
synthetic=False, | synthetic=False, | ||||
) | ) | ||||
return [with_revision, with_release, with_directory, with_content] | return [with_revision, with_release, with_directory, with_content] | ||||
def get_revisions_with_parents(): | def get_revisions_with_parents(): | ||||
""" | """ | ||||
Revisions with real revisions as parents | Revisions with real revisions as parents | ||||
""" | """ | ||||
return [ | return [ | ||||
Revision( | Revision( | ||||
id=hash_to_bytes("37580d63b8dcc0ec73e74994e66896858542844c"), | |||||
message=b"hello", | message=b"hello", | ||||
date=swh_model_data.DATES[0], | date=swh_model_data.DATES[0], | ||||
committer=swh_model_data.COMMITTERS[0], | committer=swh_model_data.COMMITTERS[0], | ||||
author=swh_model_data.COMMITTERS[0], | author=swh_model_data.COMMITTERS[0], | ||||
committer_date=swh_model_data.DATES[0], | committer_date=swh_model_data.DATES[0], | ||||
type=RevisionType.GIT, | type=RevisionType.GIT, | ||||
directory=b"\x01" * 20, | directory=b"\x01" * 20, | ||||
synthetic=False, | synthetic=False, | ||||
Show All 18 Lines |