Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123857
D3572.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D3572.diff
View Options
diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py
--- a/swh/storage/tests/test_storage.py
+++ b/swh/storage/tests/test_storage.py
@@ -2939,7 +2939,14 @@
assert list(missing_snapshots) == [missing_snapshot.id]
- def test_stat_counters(self, swh_storage):
+ def test_stat_counters(self, swh_storage, sample_data_model):
+ origin = sample_data_model["origin"][0]
+ snapshot = sample_data_model["snapshot"][0]
+ revision = sample_data_model["revision"][0]
+ release = sample_data_model["release"][0]
+ directory = sample_data_model["directory"][0]
+ content = sample_data_model["content"][0]
+
expected_keys = ["content", "directory", "origin", "revision"]
# Initially, all counters are 0
@@ -2952,7 +2959,7 @@
# Add a content. Only the content counter should increase.
- swh_storage.content_add([data.cont])
+ swh_storage.content_add([content])
swh_storage.refresh_stat_counters()
counters = swh_storage.stat_counters()
@@ -2965,28 +2972,27 @@
# Add other objects. Check their counter increased as well.
- swh_storage.origin_add([data.origin2])
- origin_url = data.origin2["url"]
+ swh_storage.origin_add([origin])
visit = OriginVisit(
- origin=origin_url, date=data.date_visit2, type=data.type_visit2,
+ origin=origin.url, date=data.date_visit2, type=data.type_visit2,
)
origin_visit1 = swh_storage.origin_visit_add([visit])[0]
- swh_storage.snapshot_add([data.snapshot])
+ swh_storage.snapshot_add([snapshot])
swh_storage.origin_visit_status_add(
[
OriginVisitStatus(
- origin=origin_url,
+ origin=origin.url,
visit=origin_visit1.visit,
date=now(),
status="ongoing",
- snapshot=data.snapshot["id"],
+ snapshot=snapshot.id,
)
]
)
- swh_storage.directory_add([data.dir])
- swh_storage.revision_add([data.revision])
- swh_storage.release_add([data.release])
+ swh_storage.directory_add([directory])
+ swh_storage.revision_add([revision])
+ swh_storage.release_add([release])
swh_storage.refresh_stat_counters()
counters = swh_storage.stat_counters()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 4:53 AM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220268
Attached To
D3572: test_storage: stat_counters: Use data model object
Event Timeline
Log In to Comment