Skip to content

Commit

Permalink
test: broken tests part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
dleard committed Jan 31, 2025
1 parent fe97df6 commit d835da8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def test_cas_admin_approves_operation(self):
assert operator.is_new is False
assert operator.verified_by == self.user
assert operator.verified_at.strftime("%Y-%m-%d") == now.strftime("%Y-%m-%d")
operation.refresh_from_db()

self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.APPROVED,
Expand Down Expand Up @@ -116,6 +117,7 @@ def test_cas_admin_declines_operation(self):
assert operation_after_put.verified_by == self.user
assert operation_after_put.bc_obps_regulated_operation is None

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.DECLINED,
operator_legal_name=operation.operator.legal_name,
Expand Down Expand Up @@ -154,6 +156,7 @@ def test_cas_admin_requests_changes_on_operation(self):
assert operation_after_put.verified_by is None
assert operation_after_put.bc_obps_regulated_operation is None

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CHANGES_REQUESTED,
operator_legal_name=operation.operator.legal_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def test_industry_user_update_operation_with_submit(self):
assert response.status_code == 200
assert response.json() == {"name": "New name"}

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CONFIRMATION,
operator_legal_name=operation.operator.legal_name,
Expand Down Expand Up @@ -310,6 +311,7 @@ def test_industry_user_update_operation_with_updated_point_of_contact(self):
assert updated_contact2.first_name == 'Homer'
assert updated_contact2.email == '[email protected]'

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CONFIRMATION,
operator_legal_name=operation.operator.legal_name,
Expand Down Expand Up @@ -525,6 +527,7 @@ def test_industry_user_update_operation_with_changes_requested_status(self):
assert retrieved_operation.submission_date - datetime.now(timezone.utc) < timedelta(seconds=10)
assert retrieved_operation.status == Operation.Statuses.PENDING

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CONFIRMATION,
operator_legal_name=retrieved_operation.operator.legal_name,
Expand Down Expand Up @@ -573,6 +576,7 @@ def test_industry_user_update_operation_with_pending_status(self):
assert retrieved_operation.submission_date - datetime.now(timezone.utc) < timedelta(seconds=10)
assert retrieved_operation.status == Operation.Statuses.PENDING

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CONFIRMATION,
operator_legal_name=retrieved_operation.operator.legal_name,
Expand Down Expand Up @@ -621,6 +625,8 @@ def test_industry_user_update_operation_with_declined_status(self):
# assert that operation's submission_date has been updated to the current time (approximately)
assert retrieved_operation.submission_date - datetime.now(timezone.utc) < timedelta(seconds=10)
assert retrieved_operation.status == Operation.Statuses.PENDING

operation.refresh_from_db()
self.mock_send_boro_id_application_email.assert_called_once_with(
application_state=BoroIdApplicationStates.CONFIRMATION,
operator_legal_name=retrieved_operation.operator.legal_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ def test_cas_admin_approves_access_request_with_existing_operator(self, mocker):
def test_cas_admin_approves_admin_access_request_with_new_operator(self, mocker):
# In this test we are testing the user operator status change and not the operator change,
# so we have to mark the operator as is_new=False and status=APPROVED so we can bypass the below part and can get to the email sending part
operator = operator_baker({'status': Operator.Statuses.APPROVED, 'is_new': False, 'created_by': self.user})
operator = operator_baker({'status': Operator.Statuses.APPROVED, 'is_new': False})
operator.refresh_from_db()
user_operator = user_operator_baker({'operator': operator, 'user': operator.created_by})

mock_send_operator_access_request_email = mocker.patch(
"service.user_operator_service.send_operator_access_request_email"
)
Expand Down Expand Up @@ -175,13 +177,13 @@ def test_cas_admin_approves_admin_access_request_with_new_operator(self, mocker)
)

def test_cas_admin_declines_access_request(self, mocker):
user = baker.make(User)
operator = operator_baker()
operator.status = Operator.Statuses.APPROVED
operator.is_new = False
operator.save(update_fields=["status", "is_new"])
user_operator = user_operator_baker()
user_operator.user_id = user.user_guid
user_operator.refresh_from_db()
user_operator.user_id = user_operator.created_by_id
user_operator.operator = operator
user_operator.save(update_fields=["user_id", "operator_id"])
# Assigning contacts to the operator of the user_operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def test_cas_analyst_approves_access_request_with_existing_operator(self, mocker
def test_cas_director_approves_admin_access_request_with_new_operator(self, mocker):
# In this test we are testing the user operator status change and not the operator change,
# so we have to mark the operator as is_new=False and status=APPROVED so we can bypass the below part and can get to the email sending part
operator = operator_baker({'status': Operator.Statuses.APPROVED, 'is_new': False, 'created_by': self.user})
operator = operator_baker({'status': Operator.Statuses.APPROVED, 'is_new': False})
operator.refresh_from_db()
user_operator = user_operator_baker({'operator': operator, 'user': operator.created_by})
mock_send_operator_access_request_email = mocker.patch(
"service.user_operator_service_v2.send_operator_access_request_email"
Expand Down

0 comments on commit d835da8

Please sign in to comment.