diff --git a/bc_obps/service/tests/test_operation_service_v2.py b/bc_obps/service/tests/test_operation_service_v2.py index f6392ce724..d7eba959b3 100644 --- a/bc_obps/service/tests/test_operation_service_v2.py +++ b/bc_obps/service/tests/test_operation_service_v2.py @@ -41,22 +41,26 @@ def set_up_valid_mock_operation(purpose: Operation.Purposes): operation = baker.make_recipe('utils.operation', status=Operation.Statuses.DRAFT, registration_purpose=purpose) # create mock valid operation rep - address = baker.make_recipe('utils.address') + address = baker.make_recipe('registration.tests.utils.address') operation_representative = baker.make_recipe( - 'utils.contact', business_role=BusinessRole.objects.get(role_name='Operation Representative'), address=address + 'registration.tests.utils.contact', + business_role=BusinessRole.objects.get(role_name='Operation Representative'), + address=address, ) operation.contacts.set([operation_representative]) # create facility for operation - baker.make_recipe('utils.facility_designated_operation_timeline', operation=operation) + baker.make_recipe('registration.tests.utils.facility_designated_operation_timeline', operation=operation) # activity operation.activities.set([baker.make(Activity)]) # docs - boundary_map = baker.make_recipe('utils.document', type=DocumentType.objects.get(name='boundary_map')) + boundary_map = baker.make_recipe( + 'registration.tests.utils.document', type=DocumentType.objects.get(name='boundary_map') + ) process_flow_diagram = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='process_flow_diagram') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='process_flow_diagram') ) operation.documents.set([boundary_map, process_flow_diagram]) @@ -64,14 +68,14 @@ def set_up_valid_mock_operation(purpose: Operation.Purposes): if purpose == Operation.Purposes.NEW_ENTRANT_OPERATION: # statutory dec if new entrant new_entrant_application = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='new_entrant_application') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='new_entrant_application') ) operation.documents.add(new_entrant_application) operation.date_of_first_shipment = "On or after April 1, 2024" if purpose == Operation.Purposes.OPTED_IN_OPERATION: # opt in record - opted_in_operation_detail = baker.make_recipe('utils.opted_in_operation_detail') + opted_in_operation_detail = baker.make_recipe('registration.tests.utils.opted_in_operation_detail') operation.opted_in_operation = opted_in_operation_detail operation.save() return operation @@ -80,16 +84,18 @@ def set_up_valid_mock_operation(purpose: Operation.Purposes): class TestOperationServiceV2: @staticmethod def test_raises_error_if_operation_does_not_belong_to_user(): - user = baker.make_recipe( - 'utils.industry_operator_user', - ) - baker.make_recipe('utils.approved_user_operator', user=user) + user = baker.make_recipe('registration.tests.utils.industry_operator_user') + baker.make_recipe('registration.tests.utils.approved_user_operator', user=user) random_operator = baker.make_recipe( - 'utils.operator', cra_business_number=123456789, bc_corporate_registry_number='abc1234567' + 'registration.tests.utils.operator', + cra_business_number=123456789, + bc_corporate_registry_number='abc1234567', ) operation = baker.make_recipe( - 'utils.operation', operator=random_operator, registration_purpose='Potential Reporting Operation' + 'registration.tests.utils.operation', + operator=random_operator, + registration_purpose='Potential Reporting Operation', ) payload = OperationInformationIn( @@ -106,7 +112,7 @@ def test_raises_error_if_operation_does_not_belong_to_user(): @staticmethod def test_assigns_single_selected_purpose(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -125,13 +131,12 @@ def test_assigns_single_selected_purpose(): operation.refresh_from_db() # refresh the operation object to get the updated audit columns assert operation.updated_at is not None - assert operation.updated_by == approved_user_operator.user assert operation.registration_purpose == Operation.Purposes.REPORTING_OPERATION @staticmethod def test_remove_opted_in_operation_detail(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') - opted_in_operation_detail = baker.make_recipe('utils.opted_in_operation_detail') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') + opted_in_operation_detail = baker.make_recipe('registration.tests.utils.opted_in_operation_detail') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -155,7 +160,7 @@ def test_remove_opted_in_operation_detail(): @staticmethod def test_assigning_opted_in_operation_will_create_and_opted_in_operation_detail(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -178,7 +183,7 @@ def test_assigning_opted_in_operation_will_create_and_opted_in_operation_detail( @staticmethod def test_list_current_users_unregistered_operations(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_unregistered_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, status=Operation.Statuses.PENDING ) @@ -196,7 +201,7 @@ def test_list_current_users_unregistered_operations(): @staticmethod def test_update_operation_status_success(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = set_up_valid_mock_operation(Operation.Purposes.OPTED_IN_OPERATION) users_operation.operator = approved_user_operator.operator users_operation.save() @@ -206,7 +211,6 @@ def test_update_operation_status_success(): ) updated_operation.refresh_from_db() assert updated_operation.status == Operation.Statuses.REGISTERED - assert updated_operation.updated_by == approved_user_operator.user assert updated_operation.updated_at is not None # make sure the submission_date is set - using 2 seconds as a buffer for the test assert datetime.now(ZoneInfo("UTC")).replace(microsecond=0) - updated_operation.submission_date.replace( @@ -216,7 +220,7 @@ def test_update_operation_status_success(): @staticmethod def test_update_operation_status_fail(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, created_by=approved_user_operator.user ) @@ -230,9 +234,9 @@ def test_update_operation_status_fail(): @staticmethod def test_raises_error_if_operation_does_not_belong_to_user_when_updating_status(): user = baker.make_recipe( - 'utils.industry_operator_user', + 'registration.tests.utils.industry_operator_user', ) - approved_user_operator = baker.make_recipe('utils.approved_user_operator', user=user) + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator', user=user) random_operator = baker.make_recipe( 'utils.operator', cra_business_number=123456789, bc_corporate_registry_number='abc1234567' @@ -245,7 +249,7 @@ def test_raises_error_if_operation_does_not_belong_to_user_when_updating_status( @staticmethod def test_assign_new_contacts_to_operation_and_operator(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) payload = OperationRepresentativeIn( first_name="John", @@ -266,17 +270,17 @@ def test_assign_new_contacts_to_operation_and_operator(): assert operation.contacts.count() == 1 assert Address.objects.count() == 2 # 1 is the contact's, 1 is from the operation baker recipe operation_contact = operation.contacts.first() + operation_contact.refresh_from_db() assert operation_contact.first_name == 'John' assert operation_contact.address.street_address == '13 Street' assert operation_contact.created_at is not None - assert operation_contact.created_by == approved_user_operator.user - assert operation.updated_at is not None - assert operation.updated_by == approved_user_operator.user @staticmethod def test_assign_existing_contacts_to_operation(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') - contacts = baker.make_recipe('utils.contact', operator=approved_user_operator.operator, _quantity=5) + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') + contacts = baker.make_recipe( + 'registration.tests.utils.contact', operator=approved_user_operator.operator, _quantity=5 + ) operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) contact_to_update = contacts[0] @@ -318,15 +322,13 @@ def test_assign_existing_contacts_to_operation(): ) operation.refresh_from_db() assert operation.contacts.count() == 1 - assert operation.updated_at is not None - assert operation.updated_by == approved_user_operator.user @staticmethod def test_raises_error_if_operation_does_not_belong_to_user_when_updating_opted_in_operation_detail(): user = baker.make_recipe( - 'utils.industry_operator_user', + 'registration.tests.utils.industry_operator_user', ) - approved_user_operator = baker.make_recipe('utils.approved_user_operator', user=user) + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator', user=user) random_operator = baker.make_recipe( 'utils.operator', cra_business_number=123456789, bc_corporate_registry_number='abc1234567' @@ -337,7 +339,7 @@ def test_raises_error_if_operation_does_not_belong_to_user_when_updating_opted_i @staticmethod def test_create_or_replace_new_entrant_application(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, created_by=approved_user_operator.user ) @@ -350,14 +352,13 @@ def test_create_or_replace_new_entrant_application(): ) operation.refresh_from_db() assert operation.id == users_operation.id - assert operation.updated_by == approved_user_operator.user assert operation.updated_at is not None assert operation.date_of_first_shipment == Operation.DateOfFirstShipmentChoices.ON_OR_BEFORE_MARCH_31_2024 assert operation.documents.filter(type=DocumentType.objects.get(name='new_entrant_application')).count() == 1 @staticmethod def test_register_operation_information_new_operation(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') payload = OperationInformationIn( registration_purpose='Electricity Import Operation', @@ -374,7 +375,6 @@ def test_register_operation_information_new_operation(): operation.refresh_from_db() # check operation creation assert Operation.objects.count() == 1 - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert operation.updated_by is not None # the operation is created first, and then we add the purpose # check purpose @@ -383,7 +383,7 @@ def test_register_operation_information_new_operation(): @staticmethod def test_register_operation_information_existing_operation(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, created_by=approved_user_operator.user ) @@ -404,7 +404,6 @@ def test_register_operation_information_existing_operation(): ) operation.refresh_from_db() assert Operation.objects.count() == 1 - assert operation.updated_by == approved_user_operator.user assert operation.updated_at is not None # check purpose assert operation.registration_purpose == Operation.Purposes.POTENTIAL_REPORTING_OPERATION @@ -412,7 +411,7 @@ def test_register_operation_information_existing_operation(): @staticmethod def test_is_operation_new_entrant_information_complete_true(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -420,7 +419,7 @@ def test_is_operation_new_entrant_information_complete_true(): date_of_first_shipment=Operation.DateOfFirstShipmentChoices.ON_OR_AFTER_APRIL_1_2024, ) new_entrant_application = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='new_entrant_application') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='new_entrant_application') ) users_operation.documents.add(new_entrant_application) @@ -428,14 +427,14 @@ def test_is_operation_new_entrant_information_complete_true(): @staticmethod def test_is_operation_new_entrant_information_complete_no_date(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, registration_purpose=Operation.Purposes.NEW_ENTRANT_OPERATION, ) new_entrant_application = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='new_entrant_application') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='new_entrant_application') ) users_operation.documents.add(new_entrant_application) @@ -443,7 +442,7 @@ def test_is_operation_new_entrant_information_complete_no_date(): @staticmethod def test_is_operation_new_entrant_information_complete_no_application(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') users_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -456,7 +455,7 @@ def test_is_operation_new_entrant_information_complete_no_application(): class TestOperationServiceV2CreateOrUpdateOperation: def test_create_operation_without_multiple_operators(self): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') payload = OperationInformationIn( registration_purpose='Reporting Operation', regulated_products=[1], @@ -475,13 +474,12 @@ def test_create_operation_without_multiple_operators(self): assert operation.activities.count() == 1 assert operation.documents.count() == 2 assert operation.registration_purpose == Operation.Purposes.REPORTING_OPERATION - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert operation.updated_at is None @staticmethod def test_create_operation_with_multiple_operators(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') payload = OperationInformationIn( registration_purpose='Reporting Operation', regulated_products=[1], @@ -520,7 +518,6 @@ def test_create_operation_with_multiple_operators(): operation = OperationServiceV2.create_or_update_operation_v2(approved_user_operator.user.user_guid, payload) operation.refresh_from_db() assert Operation.objects.count() == 1 - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert MultipleOperator.objects.count() == 2 assert MultipleOperator.objects.first().bc_corporate_registry_number == 'ghj1234567' @@ -529,9 +526,11 @@ def test_create_operation_with_multiple_operators(): @staticmethod def test_update_operation_with_multiple_operators(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) - multiple_operators = baker.make_recipe('utils.multiple_operator', operation=existing_operation, _quantity=3) + multiple_operators = baker.make_recipe( + 'registration.tests.utils.multiple_operator', operation=existing_operation, _quantity=3 + ) existing_operation.multiple_operators.set(multiple_operators) payload = OperationInformationIn( @@ -582,15 +581,16 @@ def test_update_operation_with_multiple_operators(): assert operation.multiple_operators.first().legal_name == 'i am new' assert operation.multiple_operators.last().legal_name == 'i am new 2' assert operation.name == "I am updated" - assert operation.updated_by == approved_user_operator.user assert operation.updated_at is not None assert operation.registration_purpose == Operation.Purposes.REPORTING_OPERATION @staticmethod def test_update_operation_archive_multiple_operators(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) - multiple_operators = baker.make_recipe('utils.multiple_operator', operation=existing_operation, _quantity=3) + multiple_operators = baker.make_recipe( + 'registration.tests.utils.multiple_operator', operation=existing_operation, _quantity=3 + ) existing_operation.multiple_operators.set(multiple_operators) payload = OperationInformationIn( @@ -614,15 +614,16 @@ def test_update_operation_archive_multiple_operators(): operation.refresh_from_db() assert Operation.objects.count() == 1 assert operation.multiple_operators.count() == 0 - assert operation.updated_by == approved_user_operator.user assert operation.updated_at is not None @staticmethod def test_update_operation_with_operation_representatives_with_address(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) contacts = baker.make_recipe( - 'utils.contact', business_role=BusinessRole.objects.get(role_name='Operation Representative'), _quantity=3 + 'registration.tests.utils.contact', + business_role=BusinessRole.objects.get(role_name='Operation Representative'), + _quantity=3, ) payload = OperationInformationInUpdate( @@ -647,13 +648,12 @@ def test_update_operation_with_operation_representatives_with_address(): operation.refresh_from_db() assert Operation.objects.count() == 1 assert operation.contacts.count() == 3 - assert operation.updated_by == approved_user_operator.user assert operation.updated_at is not None class TestOperationServiceV2UpdateOperation: def test_update_operation_fails_if_operation_not_registered(self): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -676,7 +676,7 @@ def test_update_operation_fails_if_operation_not_registered(self): OperationServiceV2.update_operation(approved_user_operator.user.user_guid, payload, existing_operation.id) def test_update_operation(self): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -701,13 +701,12 @@ def test_update_operation(self): assert Operation.objects.count() == 1 assert operation.activities.count() == 1 assert operation.documents.count() == 2 - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert operation.updated_at is not None assert operation.registration_purpose == Operation.Purposes.POTENTIAL_REPORTING_OPERATION def test_update_operation_with_no_regulated_products(self): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -732,14 +731,13 @@ def test_update_operation_with_no_regulated_products(self): assert Operation.objects.count() == 1 assert operation.activities.count() == 1 assert operation.documents.count() == 2 - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert operation.updated_at is not None assert operation.regulated_products.count() == 0 assert operation.registration_purpose == Operation.Purposes.OBPS_REGULATED_OPERATION def test_update_operation_with_new_entrant_application_data(self): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') existing_operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -767,7 +765,6 @@ def test_update_operation_with_new_entrant_application_data(self): assert Operation.objects.count() == 1 assert operation.activities.count() == 1 assert operation.documents.count() == 3 - assert operation.created_by == approved_user_operator.user assert operation.created_at is not None assert operation.updated_at is not None assert operation.date_of_first_shipment == Operation.DateOfFirstShipmentChoices.ON_OR_BEFORE_MARCH_31_2024 @@ -778,7 +775,7 @@ def test_update_operation_with_new_entrant_application_data(self): class TestOperationServiceV2CheckCurrentUsersRegisteredOperation: def test_check_current_users_registered_operation_returns_true(self): # Create a user operator and a registered operation - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') # Create an operation with status 'Registered' baker.make_recipe( @@ -812,7 +809,7 @@ def test_check_current_users_registered_operation_returns_true(self): def test_check_current_users_registered_operation_returns_false(self): # Create a user operator and an operation with a non-registered status - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') # Create an operation with a non-registered status baker.make_recipe( @@ -934,14 +931,14 @@ class TestHandleChangeOfRegistrationPurpose: @staticmethod def test_old_purpose_opted_in(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, registration_purpose=Operation.Purposes.OPTED_IN_OPERATION, opt_in=True, ) - opted_in_operation_detail = baker.make_recipe('utils.opted_in_operation_detail') + opted_in_operation_detail = baker.make_recipe('registration.tests.utils.opted_in_operation_detail') operation.opted_in_operation = opted_in_operation_detail operation.save() @@ -966,19 +963,21 @@ def test_old_purpose_opted_in(): @staticmethod def test_old_purpose_new_entrant(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, registration_purpose=Operation.Purposes.NEW_ENTRANT_OPERATION, date_of_first_shipment=Operation.DateOfFirstShipmentChoices.ON_OR_BEFORE_MARCH_31_2024, ) - boundary_map = baker.make_recipe('utils.document', type=DocumentType.objects.get(name='boundary_map')) + boundary_map = baker.make_recipe( + 'registration.tests.utils.document', type=DocumentType.objects.get(name='boundary_map') + ) process_flow_diagram = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='process_flow_diagram') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='process_flow_diagram') ) new_entrant_application = baker.make_recipe( - 'utils.document', type=DocumentType.objects.get(name='new_entrant_application') + 'registration.tests.utils.document', type=DocumentType.objects.get(name='new_entrant_application') ) operation.documents.set([new_entrant_application, boundary_map, process_flow_diagram]) @@ -1005,7 +1004,7 @@ def test_old_purpose_new_entrant(): @staticmethod def test_new_purpose_eio(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -1038,7 +1037,7 @@ def test_new_purpose_eio(): @staticmethod def test_new_purpose_reporting(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') products = baker.make_recipe('utils.regulated_product', _quantity=3) activities = baker.make(Activity, _quantity=3) activity_pks = [activity.id for activity in activities] @@ -1068,7 +1067,7 @@ def test_new_purpose_reporting(): class TestGenerateBoroId: @staticmethod def test_generates_boro_id(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -1081,7 +1080,7 @@ def test_generates_boro_id(): @staticmethod def test_raises_exception_if_operation_is_non_regulated(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -1094,7 +1093,7 @@ def test_raises_exception_if_operation_is_non_regulated(): @staticmethod def test_raises_exception_if_operation_is_not_registered(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe( 'utils.operation', operator=approved_user_operator.operator, @@ -1109,12 +1108,12 @@ def test_raises_exception_if_operation_is_not_registered(): class TestRemoveOperationRepresentative: @staticmethod def test_cannot_remove_anything_from_other_users_operations(): - user = baker.make_recipe('utils.industry_operator_user') + user = baker.make_recipe('registration.tests.utils.industry_operator_user') operation = baker.make_recipe( 'utils.operation', ) - contact1 = baker.make_recipe('utils.contact', id=1) - contact2 = baker.make_recipe('utils.contact', id=2) + contact1 = baker.make_recipe('registration.tests.utils.contact', id=1) + contact2 = baker.make_recipe('registration.tests.utils.contact', id=2) operation.contacts.add(contact1, contact2) operation.save() with pytest.raises(Exception, match="Unauthorized."): @@ -1122,10 +1121,10 @@ def test_cannot_remove_anything_from_other_users_operations(): @staticmethod def test_removes_operation_representative(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') operation = baker.make_recipe('utils.operation', operator=approved_user_operator.operator) - contact1 = baker.make_recipe('utils.contact', id=1) - contact2 = baker.make_recipe('utils.contact', id=2) + contact1 = baker.make_recipe('registration.tests.utils.contact', id=1) + contact2 = baker.make_recipe('registration.tests.utils.contact', id=2) operation.contacts.add(contact1, contact2) operation.save() @@ -1136,7 +1135,6 @@ def test_removes_operation_representative(): assert operation.contacts.count() == 1 assert operation.contacts.first().id == 1 - assert operation.updated_by == approved_user_operator.user # confirm the contact was only removed from the operation, not removed from the db assert Contact.objects.filter(id=2).exists() @@ -1145,7 +1143,7 @@ class TestUpdateOperationsOperator: @staticmethod @patch("service.data_access_service.user_service.UserDataAccessService.get_by_guid") def test_unauthorized_user_cannot_update_operations_operator(mock_get_by_guid): - cas_admin = baker.make_recipe('utils.cas_admin') + cas_admin = baker.make_recipe('registration.tests.utils.cas_admin') mock_get_by_guid.return_value = cas_admin operation = MagicMock() operator_id = uuid4() @@ -1155,7 +1153,7 @@ def test_unauthorized_user_cannot_update_operations_operator(mock_get_by_guid): @staticmethod @patch("service.data_access_service.user_service.UserDataAccessService.get_by_guid") def test_update_operations_operator_success(mock_get_by_guid): - cas_analyst = baker.make_recipe('utils.cas_analyst') + cas_analyst = baker.make_recipe('registration.tests.utils.cas_analyst') mock_get_by_guid.return_value = cas_analyst operation = baker.make_recipe('utils.operation') operator = baker.make_recipe('utils.operator') @@ -1166,7 +1164,7 @@ def test_update_operations_operator_success(mock_get_by_guid): class TestListOperationTimeline: @staticmethod def test_raise_exception_if_user_unapproved(): - user = baker.make_recipe('utils.industry_operator_user') + user = baker.make_recipe('registration.tests.utils.industry_operator_user') with pytest.raises(Exception, match="Unauthorized."): OperationServiceV2.list_operations_timeline( user.user_guid, @@ -1176,20 +1174,20 @@ def test_raise_exception_if_user_unapproved(): @staticmethod def test_gets_unfiltered_sorted_list_for_industry_user(): - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, status=OperationDesignatedOperatorTimeline.Statuses.TEMPORARILY_SHUTDOWN, ) baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, status=OperationDesignatedOperatorTimeline.Statuses.TRANSFERRED, ) baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, status=OperationDesignatedOperatorTimeline.Statuses.ACTIVE, ) @@ -1202,28 +1200,28 @@ def test_gets_unfiltered_sorted_list_for_industry_user(): ) assert timeline.count() == 2 # transferred statuses are excluded in the data access service - assert timeline[0].status == OperationDesignatedOperatorTimeline.Statuses.ACTIVE - assert timeline[1].status == OperationDesignatedOperatorTimeline.Statuses.TEMPORARILY_SHUTDOWN + assert timeline[1].status == OperationDesignatedOperatorTimeline.Statuses.ACTIVE + assert timeline[0].status == OperationDesignatedOperatorTimeline.Statuses.TEMPORARILY_SHUTDOWN @staticmethod def test_gets_filtered_sorted_list_for_industry_user(): filters = OperationTimelineFilterSchema( operation__bcghg_id='1', ) - approved_user_operator = baker.make_recipe('utils.approved_user_operator') + approved_user_operator = baker.make_recipe('registration.tests.utils.approved_user_operator') baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, operation=baker.make_recipe('utils.operation', bcghg_id=(baker.make(BcGreenhouseGasId, id='11111111111'))), ) baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, operation=baker.make_recipe('utils.operation', bcghg_id=(baker.make(BcGreenhouseGasId, id='15555555555'))), ) baker.make_recipe( - 'utils.operation_designated_operator_timeline', + 'registration.tests.utils.operation_designated_operator_timeline', operator=approved_user_operator.operator, operation=baker.make_recipe('utils.operation', bcghg_id=(baker.make(BcGreenhouseGasId, id='29999999999'))), )