Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163554
D3817.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D3817.diff
View Options
diff --git a/swh/storage/tests/algos/test_origin.py b/swh/storage/tests/algos/test_origin.py
--- a/swh/storage/tests/algos/test_origin.py
+++ b/swh/storage/tests/algos/test_origin.py
@@ -16,7 +16,7 @@
from swh.storage.interface import ListOrder
from swh.storage.utils import now
-from swh.storage.tests.test_storage import round_to_milliseconds
+from swh.storage.tests.storage_tests import round_to_milliseconds
def test_iter_origins(swh_storage):
diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py
--- a/swh/storage/tests/storage_tests.py
+++ b/swh/storage/tests/storage_tests.py
@@ -44,7 +44,7 @@
from swh.storage.common import origin_url_to_sha1 as sha1
from swh.storage.exc import HashCollision, StorageArgumentException
from swh.storage.interface import ListOrder, PagedResult, StorageInterface
-from swh.storage.utils import content_hex_hashes, now
+from swh.storage.utils import content_hex_hashes, now, round_to_milliseconds
@contextmanager
@@ -104,23 +104,6 @@
assert actual_list == expected_list, k
-def round_to_milliseconds(date):
- """Round datetime to milliseconds before insertion, so equality doesn't fail after a
- round-trip through a DB (eg. Cassandra)
-
- """
- return date.replace(microsecond=(date.microsecond // 1000) * 1000)
-
-
-def test_round_to_milliseconds():
- date = now()
-
- for (ms, expected_ms) in [(0, 0), (1000, 1000), (555555, 555000), (999500, 999000)]:
- date = date.replace(microsecond=ms)
- actual_date = round_to_milliseconds(date)
- assert actual_date.microsecond == expected_ms
-
-
class LazyContent(Content):
def with_data(self):
return Content.from_dict({**self.to_dict(), "data": b"42\n"})
diff --git a/swh/storage/tests/test_api_client.py b/swh/storage/tests/test_api_client.py
--- a/swh/storage/tests/test_api_client.py
+++ b/swh/storage/tests/test_api_client.py
@@ -8,10 +8,10 @@
import swh.storage.api.server as server
import swh.storage
from swh.storage import get_storage
-from swh.storage.tests.test_storage import (
+from swh.storage.tests.storage_tests import (
TestStorageGeneratedData as _TestStorageGeneratedData,
)
-from swh.storage.tests.test_storage import TestStorage as _TestStorage
+from swh.storage.tests.storage_tests import TestStorage as _TestStorage
# tests are executed using imported classes (TestStorage and
# TestStorageGeneratedData) using overloaded swh_storage fixture
diff --git a/swh/storage/tests/test_cassandra.py b/swh/storage/tests/test_cassandra.py
--- a/swh/storage/tests/test_cassandra.py
+++ b/swh/storage/tests/test_cassandra.py
@@ -21,8 +21,8 @@
from swh.storage.cassandra.model import ContentRow
from swh.storage.utils import now
-from swh.storage.tests.test_storage import TestStorage as _TestStorage
-from swh.storage.tests.test_storage import (
+from swh.storage.tests.storage_tests import TestStorage as _TestStorage
+from swh.storage.tests.storage_tests import (
TestStorageGeneratedData as _TestStorageGeneratedData,
)
diff --git a/swh/storage/tests/test_utils.py b/swh/storage/tests/test_utils.py
--- a/swh/storage/tests/test_utils.py
+++ b/swh/storage/tests/test_utils.py
@@ -8,6 +8,8 @@
extract_collision_hash,
content_hex_hashes,
content_bytes_hashes,
+ now,
+ round_to_milliseconds,
)
@@ -105,3 +107,12 @@
assert len(actual_content) == len(expected_content)
for algo in hashutil.DEFAULT_ALGORITHMS:
assert actual_content[algo] == expected_content[algo]
+
+
+def test_round_to_milliseconds():
+ date = now()
+
+ for (ms, expected_ms) in [(0, 0), (1000, 1000), (555555, 555000), (999500, 999000)]:
+ date = date.replace(microsecond=ms)
+ actual_date = round_to_milliseconds(date)
+ assert actual_date.microsecond == expected_ms
diff --git a/swh/storage/utils.py b/swh/storage/utils.py
--- a/swh/storage/utils.py
+++ b/swh/storage/utils.py
@@ -97,3 +97,11 @@
"""
return {algo: hash_to_bytes(content[algo]) for algo in DEFAULT_ALGORITHMS}
+
+
+def round_to_milliseconds(date):
+ """Round datetime to milliseconds before insertion, so equality doesn't fail after a
+ round-trip through a DB (eg. Cassandra)
+
+ """
+ return date.replace(microsecond=(date.microsecond // 1000) * 1000)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 10:15 AM (18 h, 45 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3231990
Attached To
D3817: tests: Fix failures after test_storage renaming to storage_tests
Event Timeline
Log In to Comment