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/.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..2c1f30f4 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 @@ -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 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 diff --git a/run_checks.py b/run_checks.py index f075e559..9467f3b5 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 @@ -12,35 +13,48 @@ # 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"] +end = int(datetime.now().timestamp() * 1000) +start = int((datetime.now() - timedelta(days=90)).timestamp() * 1000) + + +# 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, 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 + 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, start=start, end=end, 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 @@ -55,6 +69,26 @@ 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) + 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") +except ApiException as e: + print("Exception when trying to read old data: %s\n" % e) + print("Checks passed!") exit(0)