Skip to content

Commit 3bdd89a

Browse files
committed
test: add test_filters_from_unixtime
1 parent 49fcfbc commit 3bdd89a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ class Student(dj.Lookup):
374374
for i in range(100)
375375
]
376376

377+
Student.insert1((110, "Unix Time", "123-45-6789", "2022-05-06 12:11:10", 2000.0, None, 0))
378+
377379
yield Student
378380
Student.drop()
379381

tests/test_filter.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ def test_filters(token, client, Student):
6262
assert REST_records[0][6] == 0
6363

6464

65+
def test_filters_from_unixtime(token, client, Student):
66+
# unix time 1651839070: "2022-05-06 12:11:10"
67+
restriction = [
68+
dict(attributeName="student_enroll_date", operation="=", value=1651839070),
69+
]
70+
encoded_restriction = b64encode(dumps(restriction).encode("utf-8")).decode("utf-8")
71+
q = dict(limit=10, page=1, order="student_id ASC", restriction=encoded_restriction)
72+
REST_records = client.get(
73+
f'/schema/{Student.database}/table/{"Student"}/record?{urlencode(q)}',
74+
headers=dict(Authorization=f"Bearer {token}"),
75+
).json["records"]
76+
assert len(REST_records) == 1
77+
assert REST_records[0][1] == "Unix Time"
78+
79+
6580
def test_uuid_filter(token, client, Computer):
6681
"""Verify UUID can be properly restricted."""
6782
restriction = [

0 commit comments

Comments
 (0)