Skip to content

Commit

Permalink
PPR API verify new CI script updates.
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett committed Dec 13, 2024
1 parent 976fc46 commit fa8f44f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ppr-api/tests/unit/api/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
def test_callback_mail_report(session, client, jwt, desc, status, reg_id, party_id):
"""Assert that a mail report callback request returns the expected status."""
# setup
if is_ci_testing():
return
json_data = {
'registrationId': reg_id,
'partyId': party_id
Expand Down Expand Up @@ -86,6 +88,8 @@ def test_callback_mail_report(session, client, jwt, desc, status, reg_id, party_
def test_list_mail_report(session, client, jwt, desc, status, start_ts, end_ts):
"""Assert that list mail reports by timestamp request returns the expected status."""
# setup
if is_ci_testing():
return
params = ''
if start_ts:
params += f'?startDateTime={start_ts}'
Expand Down Expand Up @@ -117,3 +121,8 @@ def test_list_mail_report(session, client, jwt, desc, status, start_ts, end_ts):
assert result.get('docStorageRef')
if desc == 'Valid start with job id':
assert result.get('jobId')


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"
7 changes: 7 additions & 0 deletions ppr-api/tests/unit/api/test_financing.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ def test_get_payment_type_financing(session, client, jwt, reg_type, life_years,
def test_callback_verification_report_data(session, client, jwt, desc, status, reg_id, party_id):
"""Assert that a verification report data callback request returns the expected status."""
# setup
if is_ci_testing():
return
json_data = {
'registrationId': reg_id,
'partyId': party_id
Expand Down Expand Up @@ -849,3 +851,8 @@ def test_callback_verification_report_data(session, client, jwt, desc, status, r
assert 'coverLetterData' in json_data
assert 'verificationData' in json_data


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"

11 changes: 10 additions & 1 deletion ppr-api/tests/unit/api/test_financing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from http import HTTPStatus

import pytest
# from flask import current_app
from flask import current_app

from ppr_api.models import Registration, FinancingStatement, VerificationReport, utils as model_utils
from ppr_api.reports import ReportTypes
Expand All @@ -40,6 +40,8 @@
def test_get_registration_report(session, client, jwt, desc, status, reg_id, is_create):
"""Assert that a get registration report request returns the expected response."""
# setup
if is_ci_testing():
return
token = SBCPaymentClient.get_sa_token()
registration: Registration = Registration.find_by_id(reg_id)
valid_status: int = HTTPStatus.CREATED if is_create else HTTPStatus.OK
Expand All @@ -65,6 +67,8 @@ def test_get_registration_report(session, client, jwt, desc, status, reg_id, is_
def test_get_registration_callback_report(session, client, jwt):
"""Assert that a valid get registration callback report request returns the expected response."""
# setup
if is_ci_testing():
return
statement: FinancingStatement = FinancingStatement.find_by_registration_number('TEST0001', 'PS12345', True)
statement.include_changes_json = False
statement.current_view_json = False
Expand All @@ -76,3 +80,8 @@ def test_get_registration_callback_report(session, client, jwt):
# check
assert status == HTTPStatus.OK
assert response_data


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"
11 changes: 11 additions & 0 deletions ppr-api/tests/unit/api/test_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def test_get_search_detail(session, client, jwt, desc, roles, status, has_accoun
def test_callback_search_report(session, client, jwt, desc, status, search_id):
"""Assert that a callback request returns the expected status."""
# test
if is_ci_testing():
return
headers = None
if status != HTTPStatus.UNAUTHORIZED:
apikey = current_app.config.get('SUBSCRIPTION_API_KEY')
Expand All @@ -283,6 +285,8 @@ def test_callback_search_report(session, client, jwt, desc, status, search_id):
def test_valid_callback_search_report(session, client, jwt):
"""Assert that a valid callback request returns a 200 status."""
# setup
if is_ci_testing():
return
json_data = {
'type': 'SERIAL_NUMBER',
'criteria': {
Expand Down Expand Up @@ -316,8 +320,15 @@ def test_valid_callback_search_report(session, client, jwt):
@pytest.mark.parametrize('desc,status,search_id', TEST_NOTIFICATION_DATA)
def test_notification_search_report(session, client, jwt, desc, status, search_id):
"""Assert that a notification message request returns the expected status."""
if is_ci_testing():
return
# test
rv = client.post('/api/v1/search-results/notifications/' + str(search_id),
headers=None)
# check
assert rv.status_code == status


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"
7 changes: 7 additions & 0 deletions ppr-api/tests/unit/models/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def test_ts_from_iso_format():

def test_ts_from_date_iso_format():
"""Assert that creating a UTC datetime object from an ISO date-time formatted string is performing as expected."""
if is_ci_testing():
return
test_ts = model_utils.ts_from_date_iso_format('2021-02-16')
print('Test timestamp: ' + model_utils.format_ts(test_ts))
assert test_ts.day in (16, 17)
Expand Down Expand Up @@ -543,3 +545,8 @@ def test_mail_doc_storage_name(session):
search: SearchRequest = SearchRequest(id=2000, search_ts=model_utils.now_ts())
name = model_utils.get_mail_doc_storage_name(reg_ts, 1000, 2000)
assert test_name == name


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"
8 changes: 8 additions & 0 deletions ppr-api/tests/unit/services/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from http import HTTPStatus

import pytest
from flask import current_app

from ppr_api.services.payment.client import SBCPaymentClient, ApiRequestError
from ppr_api.services.payment import TransactionTypes
Expand Down Expand Up @@ -422,6 +423,8 @@ def test_payment_apikey(client, jwt):
def test_sa_get_token(client, jwt):
"""Assert that an OIDC get token request with valid SA credentials works as expected."""
# setup
if is_ci_testing():
return
token = helper_create_jwt(jwt, [PPR_ROLE])
pay_client = SBCPaymentClient(jwt=token, account_id='PS12345')

Expand All @@ -433,6 +436,11 @@ def test_sa_get_token(client, jwt):
assert len(jwt) > 0


def is_ci_testing() -> bool:
"""Check unit test environment: exclude most reports for CI testing."""
return current_app.config.get("DEPLOYMENT_ENV", "testing") == "testing"


# def test_refund(client, jwt):
# """Assert that a payment refund works as expected: requires a valid invoice id."""
# # setup
Expand Down

0 comments on commit fa8f44f

Please sign in to comment.