swh_storage = <swh.storage.in_memory.InMemoryStorage object at 0x7f689911ed30>
use_graph = True
@pytest.mark.parametrize(
"use_graph",
[
pytest.param(False, id="without-graph"),
pytest.param(True, id="with-graph", marks=pytest.mark.graph),
],
)
def test_ignore_displayname(swh_storage, use_graph):
"""Tests the original authorship information is used instead of
configured display names; otherwise objects would not match their hash,
and git-fsck/git-clone would fail.
This tests both with and without swh-graph, as both configurations use different
code paths to fetch revisions.
"""
date = TimestampWithTimezone.from_numeric_offset(Timestamp(1643882820, 0), 0, False)
legacy_person = Person.from_fullname(b"old me <old@example.org>")
current_person = Person.from_fullname(b"me <me@example.org>")
content = Content.from_data(b"foo")
swh_storage.content_add([content])
directory = Directory(
entries=(
DirectoryEntry(
name=b"file1", type="file", perms=0o100644, target=content.sha1_git
),
),
)
swh_storage.directory_add([directory])
revision = Revision(
message=b"rev",
author=legacy_person,
date=date,
committer=legacy_person,
committer_date=date,
parents=(),
type=RevisionType.GIT,
directory=directory.id,
synthetic=True,
)
swh_storage.revision_add([revision])
release = Release(
name=b"v1.1.0",
message=None,
author=legacy_person,
date=date,
target=revision.id,
target_type=ObjectType.REVISION,
synthetic=True,
)
swh_storage.release_add([release])
snapshot = Snapshot(
branches={
b"refs/tags/v1.1.0": SnapshotBranch(
target=release.id, target_type=TargetType.RELEASE
),
b"HEAD": SnapshotBranch(
target=revision.id, target_type=TargetType.REVISION
),
}
)
swh_storage.snapshot_add([snapshot])
# Add all objects to graph
if use_graph:
from swh.graph.naive_client import NaiveClient as GraphClient
nodes = [
str(x.swhid()) for x in [content, directory, revision, release, snapshot]
]
edges = [
(str(x.swhid()), str(y.swhid()))
for (x, y) in [
(directory, content),
(revision, directory),
(release, revision),
(snapshot, release),
(snapshot, revision),
]
]
swh_graph = unittest.mock.Mock(wraps=GraphClient(nodes=nodes, edges=edges))
else:
swh_graph = None
# Set a display name
> with swh_storage.db() as db:
E AttributeError: 'InMemoryStorage' object has no attribute 'db'
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_git_bare_cooker.py:638: AttributeError
TEST RESULT
TEST RESULT
- Run At
- May 31 2022, 6:43 PM