Skip to content

Commit 0157d26

Browse files
committed
Fix broken timestamp matching in test suite
1 parent a544cd4 commit 0157d26

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/remote_lrs_test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def test_retrieve_statement(self):
276276

277277
def test_retrieve_statement_no_microsecond(self):
278278
id_str = str(uuid.uuid4())
279-
dt = utc.localize(datetime.min)
279+
dt = utc.localize(datetime.utcnow())
280280
statement = Statement(
281281
actor=self.agent,
282282
verb=self.verb,
@@ -347,7 +347,7 @@ def test_query_statements(self):
347347
self._vars_verifier(s2, response.content.statements[1])
348348

349349
def test_query_statements_no_microsecond(self):
350-
tstamp = utc.localize(datetime.min)
350+
tstamp = utc.localize(datetime.utcnow())
351351
s1 = Statement(
352352
actor=self.agent,
353353
verb=self.verb,
@@ -601,7 +601,15 @@ def _vars_verifier(self, obj1, obj2, _ignored_attrs=['_authority', '_stored', '_
601601
ts1 = timegm(dt1.timetuple())
602602
ts2 = timegm(dt2.timetuple())
603603
self.assertEqual(ts1, ts2)
604-
self.assertEqual(round(dt1.microsecond, 3), round(dt2.microsecond, 3))
604+
605+
#
606+
# dealing in math operations on the microsecond was too much of a pain,
607+
# and the value should be truncated as opposed to rounded so it is just
608+
# as easy to deal with it in string form, so convert to string, zero pad
609+
# to 6 characters, then truncate to only the first 3 of those characters
610+
# and then string compare
611+
#
612+
self.assertEqual(str(dt1.microsecond).zfill(6)[:3], str(dt2.microsecond).zfill(6)[:3])
605613
elif isinstance(v, Base):
606614
self._vars_verifier(getattr(obj1, k), getattr(obj2, k))
607615
else:

0 commit comments

Comments
 (0)