Skip to content

Commit f1f3629

Browse files
committed
test: add check for functional tests to check old events
1 parent f08d15f commit f1f3629

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

run_checks.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from datetime import datetime, timedelta
23

34
import fingerprint_pro_server_api_sdk
45
from fingerprint_pro_server_api_sdk.rest import ApiException
@@ -13,15 +14,19 @@
1314
# create an instance of the API class
1415
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)
1516

17+
end = int(datetime.now().timestamp() * 1000)
18+
start = int((datetime.now() - timedelta(days=90)).timestamp() * 1000)
19+
20+
1621
# FingerprintApi->search_events usage example
1722
try:
18-
search_events_response = api_instance.search_events(2)
23+
search_events_response = api_instance.search_events(2, start=start, end=end)
1924
first_event = search_events_response.events[0]
2025
first_event_identification_data = first_event.products.identification.data
2126
visitor_id = first_event_identification_data.visitor_id
2227
request_id = first_event_identification_data.request_id
2328
print("\n\n\nSearch events response: \n", search_events_response)
24-
search_events_response_second_page = api_instance.search_events(2, pagination_key=search_events_response.pagination_key)
29+
search_events_response_second_page = api_instance.search_events(2, start=start, end=end, pagination_key=search_events_response.pagination_key)
2530

2631
if len(search_events_response_second_page.events) == 0:
2732
print("Second page of FingerprintApi->search_events: is empty")
@@ -61,6 +66,19 @@
6166
print("Exception when calling Async example: %s\n" % e)
6267
exit(1)
6368

69+
# Check that old events are still match expected format
70+
try:
71+
search_events_response_old = api_instance.search_events(1, start=start, end=end, reverse=True)
72+
old_event_identification_data = search_events_response_old.events[0].products.identification.data
73+
visitor_id_old = old_event_identification_data.visitor_id
74+
request_id_old = old_event_identification_data.request_id
75+
76+
api_instance.get_visits(visitor_id_old, limit=2)
77+
api_instance.get_event(request_id_old)
78+
print("\n\n\nOld events are good\n")
79+
except ApiException as e:
80+
print("Exception when trying to read old data: %s\n" % e)
81+
6482
print("Checks passed!")
6583

6684
exit(0)

0 commit comments

Comments
 (0)