def test_remove_raises_error_when_user_id_does_not_exist( self, user_context, mock_post_not_found_session, mock_detection_list_user_client, ): departing_employee_client = DepartingEmployeeService( mock_post_not_found_session, user_context, mock_detection_list_user_client) user_id = "942897397520289999" with pytest.raises(Py42UserNotOnListError) as err: departing_employee_client.remove(user_id) assert "User with ID '{}' is not currently on the departing-employee list.".format( user_id) in str(err.value)
def test_remove_posts_expected_data_and_to_expected_url( self, mock_connection, user_context, mock_get_all_response_empty, mock_detection_list_user_client, ): client = DepartingEmployeeService(mock_connection, user_context, mock_detection_list_user_client) mock_connection.post.return_value = mock_get_all_response_empty client.remove("999") # Have to convert the request data to a dict because # older versions of Python don't have deterministic order. posted_data = mock_connection.post.call_args[1]["json"] assert (posted_data["userId"] == "999" and posted_data["tenantId"] == TENANT_ID_FROM_RESPONSE) assert mock_connection.post.call_args[0][ 0] == "v2/departingemployee/remove"