Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDS-5946] AMS amendment #3161

Merged
merged 10 commits into from
Jun 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const ApplicationSummary: FC = () => {
permit.project_summary_permit_type
.map((projectType: string) => {
const project_type = parseProjectTypeLabel(projectType);
if (projectType === "AMENDMENT") {
return permit.existing_permits_authorizations.map((guid) => ({
if (projectType === "AMENDMENT" && permit?.existing_permits_authorizations) {
return permit?.existing_permits_authorizations?.map((guid) => ({
project_type,
permit_no: getPermitNumber(guid),
}));
Expand Down
3 changes: 3 additions & 0 deletions services/core-api/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ JWT_OIDC_KEY_DQ='ANtbSY6njfpPploQsF9sU26U0s7MsuLljM1E8uml8bVJE1mNsiu9MgpUvg39jEu
JWT_OIDC_KEY_QI='XLE5O360x-MhsdFXx8Vwz4304-MJg-oGSJXCK_ZWYOB_FGXFRTfebxCsSYi0YwJo-oNu96bvZCuMplzRI1liZw'

JWT_OIDC_TEST_PRIVATE_KEY_PEM="-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDfn1nKQshOSj8xw44oC2klFWSNLmK3BnHONCJ1bZfq0EQ5gIfg\ntlvB+Px8Ya+VS3OnK7Cdi4iU1fxO9ktN6c6TjmmmFevk8wIwqLthmCSF3r+3+h4e\nddj7hucMsXWv05QUrCPoL6YUUz7Cgpz7ra24rpAmK5z7lsV+f3BEvXkrUQIDAQAB\nAoGAC0G3QGI6OQ6tvbCNYGCqq043YI/8MiBl7C5dqbGZmx1ewdJBhMNJPStuckhs\nkURaDwk4+8VBW9SlvcfSJJrnZhgFMjOYSSsBtPGBIMIdM5eSKbenCCjO8Tg0BUh/\nxa3CHST1W4RQ5rFXadZ9AeNtaGcWj2acmXNO3DVETXAX3x0CQQD13LrBTEDR44ei\nlQ/4TlCMPO5bytd1pAxHnrqgMnWovSIPSShAAH1feFugH7ZGu7RoBO7pYNb6N3ia\nC1idc7yjAkEA6Nfc6c8meTRkVRAHCF24LB5GLfsjoMB0tOeEO9w9Ous1a4o+D24b\nAePMUImAp3woFoNDRfWtlNktOqLel5PjewJBAN9kBoA5o6/Rl9zeqdsIdWFmv4DB\n5lEqlEnC7HlAP+3oo3jWFO9KQqArQL1V8w2D4aCd0uJULiC9pCP7aTHvBhcCQQDb\nW0mOp436T6ZaELBfbFNulNLOzLLi5YzNRPLppfG1SRNZjbIrvTIKVL4N/YxLvQbT\nNrQw+2OdQACBJiEHsdZzAkBcsTk7frTH4yGx0VfHxXDPjfTj4wmD6gZIlcIr9lZg\n4H8UZcVFN95vEKxJiLRjAmj6g273pu9kK4ymXNEjWWJn\n-----END RSA PRIVATE KEY-----"

AMS_BEARER_TOKEN=5c6d9ClIrJS5N0PsrunACaHZUCkMcrm41oDne2KvY19D1+fKxOheeVhhf3NaBGpWr8XtmpLeGvFqnY+6RnoAOBYQYyHVKZF3T6bwJ+qh1xNoATlbUTpEvopbO47rH3xU
AMS_URL=https://test.j200.gov.bc.ca/ws/EM_CORE_NET3/auth
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ def get_all(cls):

@classmethod
def find_by_guid(cls, municipality_guid):
current_app.logger.debug(f"Looking for municipality with {municipality_guid}")
return cls.query.filter_by(municipality_guid=municipality_guid).first()

Large diffs are not rendered by default.

411 changes: 289 additions & 122 deletions services/core-api/app/api/services/ams_api_service.py

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions services/core-api/tests/services/test_ams_api_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,157 @@ def test_create_new_ams_authorization_successful_outcome(test_client):
data.get('zoning_reason'))
mock_create_new_ams_authorization.assert_called_once()
assert result[0]['trackingnumber'] == '123456'

def test_create_amendment_ams_authorization_successful_outcome(test_client):
data = {
'documents': [],
'company_alias': 'Test',
'contacts': [{
'project_contact_guid': '5ba69052-ebf7-433d-8a31-e277b412f232',
'project_guid': '4f3ce441-05a4-4df0-b51a-3726e1e78ee3',
'email': 'test@test.com',
'phone_number': '123-456-7890',
'first_name': 'Tester',
'last_name': 'Tester',
'address': {
'suite_no': '15',
'address_line_1': 'Pump Street',
'city': 'Victoria',
'sub_division_code': 'BC',
'post_code': 'V9B2T8',
'address_type_code': 'CAN'
}
}],
'ams_authorizations': {
'amendment': [
{
'project_summary_authorization_guid': 'xyz123',
'project_summary_guid': 'abcde12345',
'new_type': 'PER',
'authorization_description': 'Test desc',
'exemption_requested': True,
'is_contaminated': True
}
]
},
'agent': {
'party_guid': '81406c88-277b-402f-a9d9-38db3f00904b',
'party_type_code': 'ORG',
'phone_no': '123-456-7890',
'email': 'test@test.com',
'party_name': 'Test Agent Name',
'name': 'Test Agent Name',
'address': {
'suite_no': '20',
'address_line_1': 'Pump Street',
'city': 'Victoria',
'sub_division_code': 'BC',
'post_code': 'V9B2T3',
'address_type_code': 'CAN'
}
},
'is_legal_land_owner': False,
'is_crown_land_federal_or_provincial': True,
'is_landowner_aware_of_discharge_application': True,
'has_landowner_received_copy_of_application': True,
'legal_land_owner_name': 'Test Land owner',
'legal_land_owner_contact_number': '123-456-7890',
'legal_land_owner_email_address': 'test@test.com',
'facility_operator': {
'party_guid': '3a532eee-9d43-4662-b11d-a81e5fbc4543',
'party_type_code': 'PER',
'phone_no': '123-456-7890',
'party_name': 'Last name',
'name': 'First Last name',
'first_name': 'First',
'address': {
'suite_no': '15',
'address_line_1': 'Pump Street',
'city': 'Victoria',
'sub_division_code': 'BC',
'post_code': 'V9B2T8',
'address_type_code': 'CAN'
},
},
'zoning': True,
'facility_pid_pin_crown_file_no': '12345',
'facility_type': 'Test Facility',
'facility_desc': 'Test Facility',
'facility_latitude': '47.0000000',
'facility_longitude': '-113.0000000',
'facility_coords_source': 'GPS',
'nearest_municipality': 'abcde12345',
'is_legal_address_same_as_mailing_address': False,
'is_billing_address_same_as_mailing_address': False,
'is_billing_address_same_as_legal_address': True,
'applicant': {
'party_guid': '58336bde-ee23-4b58-ba0a-864fa033e343',
'party_type_code': 'ORG',
'phone_no': '123-456-7890',
'email': 'test@gold.com',
'party_name': 'SELECT REALTY',
'name': 'SELECT REALTY',
'address': [
{
'suite_no': '35',
'address_line_1': '15 Cancun Street',
'city': 'Victoria',
'sub_division_code': 'BC',
'post_code': 'V9B2T9',
'address_type_code': 'CAN'
},
{
'suite_no': '27B',
'address_line_1': '35 Ade street',
'city': 'Pretoria',
'sub_division_code': None,
'post_code': '29192',
'address_type_code': 'INT'
},
{
'suite_no': '27B',
'address_line_1': '35 Ade street',
'city': 'Pretoria',
'sub_division_code': None,
'post_code': '29192',
'address_type_code': 'INT'
}
],
}
}

mock_return_value = [
{'trackingnumber': '123456', 'outcome': 'Successfull',
'project_summary_authorization_guid': 'xyz123'}
]
with current_app.test_request_context() as a, patch(
"app.api.services.ams_api_service.AMSApiService.create_amendment_ams_authorization",
return_value=mock_return_value
) as create_amendment_ams_authorization:
service = AMSApiService()
result = service.create_amendment_ams_authorization(data.get('ams_authorizations'),
data.get('applicant'),
data.get('nearest_municipality'),
data.get('agent'),
data.get('contacts'),
data.get('facility_type'),
data.get('facility_desc'),
data.get('facility_latitude'),
data.get('facility_longitude'),
data.get('facility_coords_source'),
data.get('facility_coords_source_desc'),
data.get('legal_land_desc'),
data.get('facility_operator'),
data.get('legal_land_owner_name'),
data.get('legal_land_owner_contact_number'),
data.get('legal_land_owner_email_address'),
data.get('is_legal_land_owner'),
data.get('is_crown_land_federal_or_provincial'),
data.get('is_landowner_aware_of_discharge_application'),
data.get('has_landowner_received_copy_of_application'),
data.get('facility_pid_pin_crown_file_no'),
data.get('company_alias'),
data.get('zoning'),
data.get('zoning_reason'))
create_amendment_ams_authorization.assert_called_once()
assert result[0]['trackingnumber'] == '123456'
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ exports[`MineDashboard renders properly 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M224 32a96 96 0 1 1 0 192 96 96 0 1 1 0-192zm0 224A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 80h91.4c6.5 0 12.9 .4 19.2 1.2c-.6-5.7-.9-11.4-.9-17.2c0-5.1 .2-10.1 .7-15c-6.2-.7-12.6-1-19-1H178.3C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7c0-.8 0-1.5 0-2.3H416 192 32c1.2-79.7 66.2-144 146.3-144zM448 224.1a96 96 0 1 1 0 192 96 96 0 1 1 0-192zm0 224c29.6 0 56.8-10 78.5-26.9l86.2 86.2c6.2 6.2 16.4 6.2 22.6 0s6.2-16.4 0-22.6l-86.2-86.2C566 377 576 349.7 576 320.2c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128z"
d="M128 128a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM32 480c1.2-79.7 66.2-144 146.3-144h91.4c6.5 0 12.9 .4 19.2 1.2c-.6-5.7-.9-11.4-.9-17.2c0-5.1 .2-10.1 .7-15c-6.2-.7-12.6-1-19-1H178.3C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7c0-.8 0-1.5 0-2.3H416 192 32zM224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm224-31.9a96 96 0 1 1 0 192 96 96 0 1 1 0-192zm0 224c29.6 0 56.8-10 78.5-26.9l86.2 86.2c6.2 6.2 16.4 6.2 22.6 0s6.2-16.4 0-22.6l-86.2-86.2C566 377 576 349.7 576 320.2c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128z"
fill="currentColor"
/>
</svg>
Expand Down
Loading