Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163863
D6915.id25058.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D6915.id25058.diff
View Options
diff --git a/swh/web/tests/api/views/test_release.py b/swh/web/tests/api/views/test_release.py
--- a/swh/web/tests/api/views/test_release.py
+++ b/swh/web/tests/api/views/test_release.py
@@ -3,16 +3,10 @@
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
-from datetime import datetime
+from datetime import datetime, timezone
from swh.model.hashutil import hash_to_bytes, hash_to_hex
-from swh.model.model import (
- ObjectType,
- Person,
- Release,
- Timestamp,
- TimestampWithTimezone,
-)
+from swh.model.model import ObjectType, Person, Release, TimestampWithTimezone
from swh.web.common.utils import reverse
from swh.web.tests.data import random_sha1
from swh.web.tests.utils import check_api_get_responses, check_http_get_response
@@ -53,13 +47,7 @@
fullname=b"author <author@company.org>",
name=b"author",
),
- date=TimestampWithTimezone(
- timestamp=Timestamp(
- seconds=int(datetime.now().timestamp()), microseconds=0
- ),
- offset=0,
- negative_utc=False,
- ),
+ date=TimestampWithTimezone.from_datetime(datetime.now(tz=timezone.utc)),
message=b"sample release message",
name=b"sample release",
synthetic=False,
diff --git a/swh/web/tests/common/test_converters.py b/swh/web/tests/common/test_converters.py
--- a/swh/web/tests/common/test_converters.py
+++ b/swh/web/tests/common/test_converters.py
@@ -13,7 +13,6 @@
Release,
Revision,
RevisionType,
- Timestamp,
TimestampWithTimezone,
)
from swh.web.common import converters
@@ -211,20 +210,14 @@
def test_from_release():
"""Convert release model object to a dict should be ok"""
- ts = int(
- datetime.datetime(
- 2015, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc
- ).timestamp()
+ date = TimestampWithTimezone.from_datetime(
+ datetime.datetime(2015, 1, 1, 22, 0, 0, tzinfo=datetime.timezone.utc)
)
release_input = Release(
id=hashutil.hash_to_bytes("aad23fa492a0c5fed0708a6703be875448c86884"),
target=hashutil.hash_to_bytes("5e46d564378afc44b31bb89f99d5675195fbdf67"),
target_type=ObjectType.REVISION,
- date=TimestampWithTimezone(
- timestamp=Timestamp(seconds=ts, microseconds=0),
- offset=0,
- negative_utc=False,
- ),
+ date=date,
author=Person(
name=b"author name",
fullname=b"Author Name author@email",
@@ -257,10 +250,8 @@
def test_from_revision_model_object():
- ts = int(
- datetime.datetime(
- 2000, 1, 17, 11, 23, 54, tzinfo=datetime.timezone.utc
- ).timestamp()
+ date = TimestampWithTimezone.from_datetime(
+ datetime.datetime(2000, 1, 17, 11, 23, 54, tzinfo=datetime.timezone.utc)
)
revision_input = Revision(
directory=hashutil.hash_to_bytes("7834ef7e7c357ce2af928115c6c6a42b7e2a44e6"),
@@ -275,16 +266,8 @@
email=b"robot@softwareheritage.org",
),
message=b"synthetic revision message",
- date=TimestampWithTimezone(
- timestamp=Timestamp(seconds=ts, microseconds=0),
- offset=0,
- negative_utc=False,
- ),
- committer_date=TimestampWithTimezone(
- timestamp=Timestamp(seconds=ts, microseconds=0),
- offset=0,
- negative_utc=False,
- ),
+ date=date,
+ committer_date=date,
synthetic=True,
type=RevisionType.TAR,
parents=tuple(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 5:02 PM (2 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3234818
Attached To
D6915: tests: Use TimestampWithTimezone.from_datetime() instead of the constructor
Event Timeline
Log In to Comment