def test_date_to_db():
date_to_db = converters.date_to_db
assert date_to_db(None) == {"timestamp": None, "offset": 0, "neg_utc_offset": None}
> assert date_to_db(
{"timestamp": 1234567890, "offset": 120, "negative_utc": False,}
) == {
"timestamp": "2009-02-13T23:31:30+00:00",
"offset": 120,
"neg_utc_offset": False,
}
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_converters.py:13:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ts_with_tz = {'negative_utc': False, 'offset': 120, 'timestamp': 1234567890}
def date_to_db(ts_with_tz: Optional[TimestampWithTimezone]) -> Dict[str, Any]:
"""Convert a swh-model date_offset to its DB representation.
Args:
ts_with_tz: a TimestampWithTimezone object
Returns:
dict: a dictionary with three keys:
- timestamp: a date in ISO format
- offset: the UTC offset in minutes
- neg_utc_offset: a boolean indicating whether a null offset is
negative or positive.
"""
if ts_with_tz is None:
return DEFAULT_DATE
> ts = ts_with_tz.timestamp
E AttributeError: 'dict' object has no attribute 'timestamp'
.tox/py3/lib/python3.7/site-packages/swh/storage/converters.py:131: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Aug 12 2020, 11:01 AM