Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/data.py
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | return [ | ||||
type=RevisionType.GIT, | type=RevisionType.GIT, | ||||
directory=b"\x01" * 20, | directory=b"\x01" * 20, | ||||
synthetic=False, | synthetic=False, | ||||
parents=(get_revisions()[0].id, get_revisions()[1].id), | parents=(get_revisions()[0].id, get_revisions()[1].id), | ||||
) | ) | ||||
] | ] | ||||
def get_revisions_with_none_date(): | |||||
return [ | |||||
Revision( | |||||
message=b"hello", | |||||
date=None, | |||||
committer=swh_model_data.COMMITTERS[0], | |||||
author=swh_model_data.COMMITTERS[0], | |||||
committer_date=swh_model_data.DATES[0], | |||||
type=RevisionType.GIT, | |||||
directory=b"\x01" * 20, | |||||
synthetic=False, | |||||
parents=(get_revisions()[0].id, get_revisions()[1].id), | |||||
) | |||||
] | |||||
def get_directories_with_nested_path(): | def get_directories_with_nested_path(): | ||||
return [ | return [ | ||||
Directory( | Directory( | ||||
entries=( | entries=( | ||||
DirectoryEntry( | DirectoryEntry( | ||||
name=b"sub-dir", | name=b"sub-dir", | ||||
perms=0o644, | perms=0o644, | ||||
type="dir", | type="dir", | ||||
Show All 30 Lines | return [ | ||||
snapshot=None, | snapshot=None, | ||||
metadata=None, | metadata=None, | ||||
) | ) | ||||
] | ] | ||||
GRAPHQL_EXTRA_TEST_OBJECTS = { | GRAPHQL_EXTRA_TEST_OBJECTS = { | ||||
"release": get_releases_with_target(), | "release": get_releases_with_target(), | ||||
"revision": get_revisions_with_parents(), | "revision": get_revisions_with_parents() + get_revisions_with_none_date(), | ||||
"directory": get_directories_with_nested_path() | "directory": get_directories_with_nested_path() | ||||
+ get_directories_with_special_name_entries(), | + get_directories_with_special_name_entries(), | ||||
"origin_visit_status": get_visit_with_multiple_status(), | "origin_visit_status": get_visit_with_multiple_status(), | ||||
} | } | ||||
def populate_dummy_data(storage): | def populate_dummy_data(storage): | ||||
for object_type, objects in swh_model_data.TEST_OBJECTS.items(): | for object_type, objects in swh_model_data.TEST_OBJECTS.items(): | ||||
method = getattr(storage, object_type + "_add") | method = getattr(storage, object_type + "_add") | ||||
method(objects) | method(objects) | ||||
for object_type, objects in GRAPHQL_EXTRA_TEST_OBJECTS.items(): | for object_type, objects in GRAPHQL_EXTRA_TEST_OBJECTS.items(): | ||||
method = getattr(storage, object_type + "_add") | method = getattr(storage, object_type + "_add") | ||||
method(objects) | method(objects) |