Skip to content

Commit

Permalink
test: add test_filters_from_unixtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ttngu207 committed Nov 14, 2024
1 parent 49fcfbc commit 3bdd89a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ class Student(dj.Lookup):
for i in range(100)
]

Student.insert1((110, "Unix Time", "123-45-6789", "2022-05-06 12:11:10", 2000.0, None, 0))

yield Student
Student.drop()

Expand Down
15 changes: 15 additions & 0 deletions tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ def test_filters(token, client, Student):
assert REST_records[0][6] == 0


def test_filters_from_unixtime(token, client, Student):
# unix time 1651839070: "2022-05-06 12:11:10"
restriction = [
dict(attributeName="student_enroll_date", operation="=", value=1651839070),
]
encoded_restriction = b64encode(dumps(restriction).encode("utf-8")).decode("utf-8")
q = dict(limit=10, page=1, order="student_id ASC", restriction=encoded_restriction)
REST_records = client.get(
f'/schema/{Student.database}/table/{"Student"}/record?{urlencode(q)}',
headers=dict(Authorization=f"Bearer {token}"),
).json["records"]
assert len(REST_records) == 1
assert REST_records[0][1] == "Unix Time"


def test_uuid_filter(token, client, Computer):
"""Verify UUID can be properly restricted."""
restriction = [
Expand Down

0 comments on commit 3bdd89a

Please sign in to comment.