archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7f0e85b41588>
@given(revision())
> def test_lookup_directory_with_revision_with_path_to_file_and_data(
archive_data, revision
):
.tox/py3/lib/python3.7/site-packages/swh/web/tests/common/test_service.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/common/test_service.py:478: in test_lookup_directory_with_revision_with_path_to_file_and_data
revision, expected_dir_entry["name"], with_data=True
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sha1_git = 'a25bcf7a878ad1c4e798eafc683915fad2d847a9', dir_path = 'README.md'
with_data = True
def lookup_directory_with_revision(sha1_git, dir_path=None, with_data=False):
"""Return information on directory pointed by revision with sha1_git.
If dir_path is not provided, display top level directory.
Otherwise, display the directory pointed by dir_path (if it exists).
Args:
sha1_git: revision's hash.
dir_path: optional directory pointed to by that revision.
with_data: boolean that indicates to retrieve the raw data if the path
resolves to a content. Default to False (for the api)
Returns:
Information on the directory pointed to by that revision.
Raises:
BadInputExc in case of unknown algo_hash or bad hash.
NotFoundExc either if the revision is not found or the path referenced
does not exist.
NotImplementedError in case of dir_path exists but do not reference a
type 'dir' or 'file'.
"""
sha1_git_bin = _to_sha1_bin(sha1_git)
revision = _first_element(storage.revision_get([sha1_git_bin]))
if not revision:
raise NotFoundExc("Revision %s not found" % sha1_git)
dir_sha1_git_bin = revision["directory"]
if dir_path:
paths = dir_path.strip(os.path.sep).split(os.path.sep)
entity = storage.directory_entry_get_by_path(
dir_sha1_git_bin, list(map(lambda p: p.encode("utf-8"), paths))
)
if not entity:
raise NotFoundExc(
"Directory or File '%s' pointed to by revision %s not found"
% (dir_path, sha1_git)
)
else:
entity = {"type": "dir", "target": dir_sha1_git_bin}
if entity["type"] == "dir":
directory_entries = storage.directory_ls(entity["target"]) or []
return {
"type": "dir",
"path": "." if not dir_path else dir_path,
"revision": sha1_git,
"content": list(map(converters.from_directory_entry, directory_entries)),
}
elif entity["type"] == "file": # content
content = _first_element(storage.content_find({"sha1_git": entity["target"]}))
if not content:
raise NotFoundExc(f"Content not found for revision {sha1_git}")
> content_d = content.to_dict()
E AttributeError: 'dict' object has no attribute 'to_dict'
.tox/py3/lib/python3.7/site-packages/swh/web/common/service.py:805: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Aug 4 2020, 11:19 AM