From fec0862496cd55f25f018ba62b4d6806bc4aa936 Mon Sep 17 00:00:00 2001 From: Leo Dube Date: Fri, 13 Oct 2023 13:29:39 -0700 Subject: [PATCH] Properly patch good_standing --- .../tests/unit/services/test_authorization.py | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/legal-api/tests/unit/services/test_authorization.py b/legal-api/tests/unit/services/test_authorization.py index 6a3ab8b6c0..47b77ea865 100644 --- a/legal-api/tests/unit/services/test_authorization.py +++ b/legal-api/tests/unit/services/test_authorization.py @@ -24,7 +24,7 @@ from http import HTTPStatus import pytest -from unittest.mock import patch +from unittest.mock import patch, PropertyMock from flask import jsonify from registry_schemas.example_data import AGM_LOCATION_CHANGE, ALTERATION_FILING_TEMPLATE, ANNUAL_REPORT, \ CORRECTION_AR, CHANGE_OF_REGISTRATION_TEMPLATE, RESTORATION, FILING_TEMPLATE, DISSOLUTION, PUT_BACK_ON, \ @@ -1095,22 +1095,18 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me FilingKey.COD_CP, FilingKey.CORRCTN, FilingKey.COURT_ORDER, - FilingKey.VOL_DISS, FilingKey.ADM_DISS, FilingKey.REGISTRARS_NOTATION, FilingKey.REGISTRARS_ORDER, FilingKey.SPECIAL_RESOLUTION])), ('staff_active_corps', True, Business.State.ACTIVE, ['BC', 'BEN', 'CC', 'ULC'], 'staff', [STAFF_ROLE], expected_lookup([FilingKey.ADMN_FRZE, - FilingKey.AGM_LOCATION_CHANGE, FilingKey.ALTERATION, FilingKey.AR_CORPS, FilingKey.COA_CORPS, FilingKey.COD_CORPS, - FilingKey.CONSENT_CONTINUATION_OUT, FilingKey.CORRCTN, FilingKey.COURT_ORDER, - FilingKey.VOL_DISS, FilingKey.ADM_DISS, FilingKey.REGISTRARS_NOTATION, FilingKey.REGISTRARS_ORDER, @@ -1122,7 +1118,6 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me FilingKey.CONV_FIRMS, FilingKey.CORRCTN_FIRMS, FilingKey.COURT_ORDER, - FilingKey.VOL_DISS_FIRMS, FilingKey.ADM_DISS_FIRMS, FilingKey.REGISTRARS_NOTATION, FilingKey.REGISTRARS_ORDER])), @@ -1132,21 +1127,16 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me expected_lookup([FilingKey.AR_CP, FilingKey.COA_CP, FilingKey.COD_CP, - FilingKey.VOL_DISS, FilingKey.SPECIAL_RESOLUTION])), ('general_user_corps', True, Business.State.ACTIVE, ['BC', 'BEN', 'CC', 'ULC'], 'general', [BASIC_USER], - expected_lookup([FilingKey.AGM_LOCATION_CHANGE, - FilingKey.ALTERATION, + expected_lookup([FilingKey.ALTERATION, FilingKey.AR_CORPS, FilingKey.COA_CORPS, FilingKey.COD_CORPS, - FilingKey.CONSENT_CONTINUATION_OUT, - FilingKey.VOL_DISS, FilingKey.TRANSITION])), ('general_user_llc', True, Business.State.ACTIVE, ['LLC'], 'general', [BASIC_USER], []), ('general_user_firms', True, Business.State.ACTIVE, ['SP', 'GP'], 'general', [BASIC_USER], - expected_lookup([FilingKey.CHANGE_OF_REGISTRATION, - FilingKey.VOL_DISS_FIRMS])), + expected_lookup([FilingKey.CHANGE_OF_REGISTRATION])), # historical business - staff user ('staff_historical_cp', True, Business.State.HISTORICAL, ['CP'], 'staff', [STAFF_ROLE], @@ -1187,12 +1177,12 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me for legal_type in legal_types: business = None - with patch.object(Business, 'good_standing', return_value=False): - if business_exists: - identifier = (f'BC{random.SystemRandom().getrandbits(0x58)}')[:9] - business = factory_business(identifier=identifier, - entity_type=legal_type, - state=state) + identifier = (f'BC{random.SystemRandom().getrandbits(0x58)}')[:9] + business = factory_business(identifier=identifier, + entity_type=legal_type, + state=state) + with patch.object(type(business), 'good_standing', new_callable=PropertyMock) as mock_good_standing: + mock_good_standing.return_value = False filing_types = get_allowed_filings(business, state, legal_type, jwt) assert filing_types == expected