From f08d15f7919d52a3c9ea24aef65ec390485b4a4e Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Mon, 24 Mar 2025 20:34:53 +0100 Subject: [PATCH 1/5] chore: don't use outdated events in functional tests --- .env.example | 2 -- run_checks.py | 34 ++++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.env.example b/.env.example index 979b570e..706fa91d 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,4 @@ PRIVATE_KEY= -REQUEST_ID= -VISITOR_ID= VISITOR_ID_TO_DELETE= # for delete visitor example REQUEST_ID_TO_UPDATE= # for update event example # put 'eu' or 'ap' if necessary, 'us' is default diff --git a/run_checks.py b/run_checks.py index f075e559..d1cf03fb 100644 --- a/run_checks.py +++ b/run_checks.py @@ -12,35 +12,41 @@ # create an instance of the API class api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration) -visitor_id = os.environ["VISITOR_ID"] -request_id = os.environ["REQUEST_ID"] +# FingerprintApi->search_events usage example try: - visits_response = api_instance.get_visits(visitor_id, limit=2) - pagination_key = visits_response.pagination_key - print("\n\n\nVisits response: \n", visits_response) + search_events_response = api_instance.search_events(2) + first_event = search_events_response.events[0] + first_event_identification_data = first_event.products.identification.data + visitor_id = first_event_identification_data.visitor_id + request_id = first_event_identification_data.request_id + print("\n\n\nSearch events response: \n", search_events_response) + search_events_response_second_page = api_instance.search_events(2, pagination_key=search_events_response.pagination_key) - visits_response = api_instance.get_visits( - visitor_id, limit=2, pagination_key=pagination_key) + if len(search_events_response_second_page.events) == 0: + print("Second page of FingerprintApi->search_events: is empty") + exit(1) except ApiException as e: - print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e) + print("Exception when calling FingerprintApi->search_events: %s\n" % e) exit(1) +# Use existing visitor_id from FingerprintApi->search_events response to check FingerprintApi->get_visits method try: - events_response = api_instance.get_event(request_id) - print("\n\n\nEvent response: \n", events_response.products) + visits_response = api_instance.get_visits(visitor_id, limit=2) + print("\n\n\nVisits response: \n", visits_response) except ApiException as e: - print("Exception when calling DefaultApi->get_event: %s\n" % e) + print("Exception when calling FingerprintApi->get_visits: %s\n" % e) exit(1) +# Use existing request_id from FingerprintApi->search_events response to check FingerprintApi->get_event method try: - search_events_response = api_instance.search_events(2, bot="bad") - print("\n\n\nSearch events response: \n", search_events_response) + events_response = api_instance.get_event(request_id) + print("\n\n\nEvent response: \n", events_response.products) except ApiException as e: - print("Exception when calling DefaultApi->search_events: %s\n" % e) + print("Exception when calling FingerprintApi->get_event: %s\n" % e) exit(1) # Async methods examples From f1f36295cff558e30a1489a4e5fb027077fb70dd Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Tue, 25 Mar 2025 13:53:48 +0100 Subject: [PATCH 2/5] test: add check for functional tests to check old events --- run_checks.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/run_checks.py b/run_checks.py index d1cf03fb..0c497590 100644 --- a/run_checks.py +++ b/run_checks.py @@ -1,4 +1,5 @@ import os +from datetime import datetime, timedelta import fingerprint_pro_server_api_sdk from fingerprint_pro_server_api_sdk.rest import ApiException @@ -13,15 +14,19 @@ # create an instance of the API class api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration) +end = int(datetime.now().timestamp() * 1000) +start = int((datetime.now() - timedelta(days=90)).timestamp() * 1000) + + # FingerprintApi->search_events usage example try: - search_events_response = api_instance.search_events(2) + search_events_response = api_instance.search_events(2, start=start, end=end) first_event = search_events_response.events[0] first_event_identification_data = first_event.products.identification.data visitor_id = first_event_identification_data.visitor_id request_id = first_event_identification_data.request_id print("\n\n\nSearch events response: \n", search_events_response) - search_events_response_second_page = api_instance.search_events(2, pagination_key=search_events_response.pagination_key) + search_events_response_second_page = api_instance.search_events(2, start=start, end=end, pagination_key=search_events_response.pagination_key) if len(search_events_response_second_page.events) == 0: print("Second page of FingerprintApi->search_events: is empty") @@ -61,6 +66,19 @@ print("Exception when calling Async example: %s\n" % e) exit(1) +# Check that old events are still match expected format +try: + search_events_response_old = api_instance.search_events(1, start=start, end=end, reverse=True) + old_event_identification_data = search_events_response_old.events[0].products.identification.data + visitor_id_old = old_event_identification_data.visitor_id + request_id_old = old_event_identification_data.request_id + + api_instance.get_visits(visitor_id_old, limit=2) + api_instance.get_event(request_id_old) + print("\n\n\nOld events are good\n") +except ApiException as e: + print("Exception when trying to read old data: %s\n" % e) + print("Checks passed!") exit(0) From 093e44511d36a4ee880a65793cbac5830f56e587 Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Thu, 27 Mar 2025 13:51:57 +0100 Subject: [PATCH 3/5] chore: apply review findings --- run_checks.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/run_checks.py b/run_checks.py index 0c497590..9467f3b5 100644 --- a/run_checks.py +++ b/run_checks.py @@ -21,6 +21,9 @@ # FingerprintApi->search_events usage example try: search_events_response = api_instance.search_events(2, start=start, end=end) + if len(search_events_response.events) == 0: + print("FingerprintApi.search_events: is empty") + exit(1) first_event = search_events_response.events[0] first_event_identification_data = first_event.products.identification.data visitor_id = first_event_identification_data.visitor_id @@ -29,11 +32,11 @@ search_events_response_second_page = api_instance.search_events(2, start=start, end=end, pagination_key=search_events_response.pagination_key) if len(search_events_response_second_page.events) == 0: - print("Second page of FingerprintApi->search_events: is empty") + print("Second page of FingerprintApi.search_events: is empty") exit(1) except ApiException as e: - print("Exception when calling FingerprintApi->search_events: %s\n" % e) + print("Exception when calling FingerprintApi.search_events: %s\n" % e) exit(1) # Use existing visitor_id from FingerprintApi->search_events response to check FingerprintApi->get_visits method @@ -42,7 +45,7 @@ print("\n\n\nVisits response: \n", visits_response) except ApiException as e: - print("Exception when calling FingerprintApi->get_visits: %s\n" % e) + print("Exception when calling FingerprintApi.get_visits: %s\n" % e) exit(1) # Use existing request_id from FingerprintApi->search_events response to check FingerprintApi->get_event method @@ -51,7 +54,7 @@ print("\n\n\nEvent response: \n", events_response.products) except ApiException as e: - print("Exception when calling FingerprintApi->get_event: %s\n" % e) + print("Exception when calling FingerprintApi.get_event: %s\n" % e) exit(1) # Async methods examples @@ -69,10 +72,17 @@ # Check that old events are still match expected format try: search_events_response_old = api_instance.search_events(1, start=start, end=end, reverse=True) + if len(search_events_response_old.events) == 0: + print("FingerprintApi.search_events: is empty for old events\n") + exit(1) old_event_identification_data = search_events_response_old.events[0].products.identification.data visitor_id_old = old_event_identification_data.visitor_id request_id_old = old_event_identification_data.request_id + if visitor_id_old == visitor_id or request_id_old == request_id: + print("Old events are identical to new\n") + exit(1) + api_instance.get_visits(visitor_id_old, limit=2) api_instance.get_event(request_id_old) print("\n\n\nOld events are good\n") From ff092289ed123369bc5c04b2087f56b7edec6baa Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Tue, 1 Apr 2025 17:17:05 +0200 Subject: [PATCH 4/5] chore: use latest ubuntu tu run tests, and python 3.13 to collect coverage --- .github/workflows/coverage-report.yml | 2 +- .github/workflows/functional_tests.yml | 2 +- .github/workflows/test.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 0ccc36ae..9e405e6f 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: "Install dependencies" run: | python -m pip install --upgrade pip diff --git a/.github/workflows/functional_tests.yml b/.github/workflows/functional_tests.yml index 0a7f3d98..e5686cd1 100644 --- a/.github/workflows/functional_tests.yml +++ b/.github/workflows/functional_tests.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false max-parallel: 1 matrix: - python-version: [ "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10" ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1c542a0..48a6001b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,11 +9,11 @@ on: jobs: tests: name: "Python ${{ matrix.python-version }}" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-latest" strategy: matrix: - python-version: [ "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10" ] steps: - uses: actions/checkout@v4 From 37989bf25a7fe9743d0d1eab274f702485c204f4 Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Tue, 1 Apr 2025 17:34:08 +0200 Subject: [PATCH 5/5] chore: remove visitor_is and request_id envs from gh workflow --- .github/workflows/functional_tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/functional_tests.yml b/.github/workflows/functional_tests.yml index e5686cd1..2c1f30f4 100644 --- a/.github/workflows/functional_tests.yml +++ b/.github/workflows/functional_tests.yml @@ -33,8 +33,6 @@ jobs: run: "python ./run_checks.py" env: PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}" - VISITOR_ID: "${{ secrets.VISITOR_ID }}" - REQUEST_ID: "${{ secrets.REQUEST_ID }}" report-status: needs: functional_tests