Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/functional/test_directory_entry.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | query_str = """ | ||||
targetType | targetType | ||||
target { | target { | ||||
...on Content { | ...on Content { | ||||
swhid | swhid | ||||
} | } | ||||
...on Directory { | ...on Directory { | ||||
swhid | swhid | ||||
} | } | ||||
...on Revision { | |||||
swhid | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
""" | """ | ||||
for entry in storage.directory_ls(directory.id, recursive=True): | for entry in storage.directory_ls(directory.id, recursive=True): | ||||
if entry["type"] == "rev": | |||||
# FIXME, Revision is not supported as a directory entry target yet | |||||
continue | |||||
query = query_str % ( | query = query_str % ( | ||||
directory.swhid(), | directory.swhid(), | ||||
entry["name"].decode(), | entry["name"].decode(), | ||||
) | ) | ||||
data, _ = utils.get_query_response( | data, _ = utils.get_query_response( | ||||
client, | client, | ||||
query, | query, | ||||
) | ) | ||||
swhid = None | swhid = None | ||||
if entry["type"] == "file" and entry["sha1_git"] is not None: | if entry["type"] == "file" and entry["sha1_git"] is not None: | ||||
swhid = CoreSWHID( | swhid = CoreSWHID( | ||||
object_type=ObjectType.CONTENT, object_id=entry["sha1_git"] | object_type=ObjectType.CONTENT, object_id=entry["sha1_git"] | ||||
) | ) | ||||
elif entry["type"] == "dir" and entry["target"] is not None: | elif entry["type"] == "dir" and entry["target"] is not None: | ||||
swhid = CoreSWHID( | swhid = CoreSWHID( | ||||
object_type=ObjectType.DIRECTORY, object_id=entry["target"] | object_type=ObjectType.DIRECTORY, object_id=entry["target"] | ||||
) | ) | ||||
elif entry["type"] == "rev" and entry["target"] is not None: | |||||
swhid = CoreSWHID( | |||||
object_type=ObjectType.REVISION, object_id=entry["target"] | |||||
) | |||||
assert data["directoryEntry"] == { | assert data["directoryEntry"] == { | ||||
"name": {"text": entry["name"].decode()}, | "name": {"text": entry["name"].decode()}, | ||||
"target": {"swhid": str(swhid)} if swhid else None, | "target": {"swhid": str(swhid)} if swhid else None, | ||||
"targetType": entry["type"], | "targetType": entry["type"], | ||||
} | } | ||||
@pytest.mark.parametrize("directory", get_directories()) | @pytest.mark.parametrize("directory", get_directories()) | ||||
Show All 25 Lines |