From 710019eac18203776d331a951bb1411b46f32093 Mon Sep 17 00:00:00 2001 From: Michael Plunkett <5885605+michplunkett@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:56:54 -0500 Subject: [PATCH] Remove unnecessary `mockdata` parameters (#1126) ## Fixes issue https://github.com/lucyparsons/OpenOversight/issues/1125 ## Description of Changes Removed the `mockdata` parameter from test functions that don't require it. ## Tests and Linting - [x] This branch is up-to-date with the `develop` branch. - [x] `pytest` passes on my local development environment. - [x] `pre-commit` passes on my local development environment. --- OpenOversight/tests/routes/test_auth.py | 78 ++++---- .../tests/routes/test_descriptions.py | 42 ++-- .../tests/routes/test_image_tagging.py | 42 ++-- OpenOversight/tests/routes/test_incidents.py | 56 +++--- OpenOversight/tests/routes/test_notes.py | 38 ++-- .../routes/test_officer_and_department.py | 188 ++++++++---------- OpenOversight/tests/routes/test_other.py | 4 +- OpenOversight/tests/routes/test_user.py | 16 +- OpenOversight/tests/routes/test_user_api.py | 29 ++- OpenOversight/tests/test_database_cache.py | 4 +- OpenOversight/tests/test_functional.py | 10 +- OpenOversight/tests/test_utils.py | 10 +- 12 files changed, 230 insertions(+), 287 deletions(-) diff --git a/OpenOversight/tests/routes/test_auth.py b/OpenOversight/tests/routes/test_auth.py index abfe13d95..c4d35b23a 100644 --- a/OpenOversight/tests/routes/test_auth.py +++ b/OpenOversight/tests/routes/test_auth.py @@ -39,7 +39,7 @@ "/auth/reset", ], ) -def test_routes_ok(route, client, mockdata): +def test_routes_ok(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.OK @@ -57,19 +57,19 @@ def test_routes_ok(route, client, mockdata): "/auth/change-email/abcd1234", ], ) -def test_route_login_required(route, client, mockdata): +def test_route_login_required(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.FOUND -def test_valid_user_can_login(mockdata, client, session): +def test_valid_user_can_login(client, session): with current_app.test_request_context(): rv, _ = login_user(client) assert rv.status_code == HTTPStatus.FOUND assert urlparse(rv.location).path == "/index" -def test_valid_user_can_login_with_email_differently_cased(mockdata, client, session): +def test_valid_user_can_login_with_email_differently_cased(client, session): with current_app.test_request_context(): form = LoginForm(email="JEN@EXAMPLE.ORG", password="dog", remember_me=True) rv = client.post(url_for("auth.login"), data=form.data, follow_redirects=False) @@ -77,7 +77,7 @@ def test_valid_user_can_login_with_email_differently_cased(mockdata, client, ses assert urlparse(rv.location).path == "/index" -def test_invalid_user_cannot_login(mockdata, client, session): +def test_invalid_user_cannot_login(client, session): with current_app.test_request_context(): form = LoginForm( email=UNCONFIRMED_USER_EMAIL, password="bruteforce", remember_me=True @@ -86,7 +86,7 @@ def test_invalid_user_cannot_login(mockdata, client, session): assert b"Invalid username or password." in rv.data -def test_user_can_logout(mockdata, client, session): +def test_user_can_logout(client, session): with current_app.test_request_context(): login_user(client) @@ -94,7 +94,7 @@ def test_user_can_logout(mockdata, client, session): assert b"You have been logged out." in rv.data -def test_user_cannot_register_with_existing_email(mockdata, client, session): +def test_user_cannot_register_with_existing_email(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = RegistrationForm( @@ -112,9 +112,7 @@ def test_user_cannot_register_with_existing_email(mockdata, client, session): assert b"Email already registered" in rv.data -def test_user_cannot_register_with_existing_email_differently_cased( - mockdata, client, session -): +def test_user_cannot_register_with_existing_email_differently_cased(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = RegistrationForm( @@ -132,7 +130,7 @@ def test_user_cannot_register_with_existing_email_differently_cased( assert b"Email already registered" in rv.data -def test_user_cannot_register_if_passwords_dont_match(mockdata, client, session): +def test_user_cannot_register_if_passwords_dont_match(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = RegistrationForm( @@ -150,7 +148,7 @@ def test_user_cannot_register_if_passwords_dont_match(mockdata, client, session) assert b"Passwords must match" in rv.data -def test_user_can_register_with_legit_credentials(mockdata, client, session, faker): +def test_user_can_register_with_legit_credentials(client, session, faker): with ( current_app.test_request_context(), TestCase.assertLogs(current_app.logger) as log, @@ -173,7 +171,7 @@ def test_user_can_register_with_legit_credentials(mockdata, client, session, fak ) -def test_user_cannot_register_with_weak_password(mockdata, client, session): +def test_user_cannot_register_with_weak_password(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = RegistrationForm( @@ -189,7 +187,7 @@ def test_user_cannot_register_with_weak_password(mockdata, client, session): assert b"A confirmation email has been sent to you." not in rv.data -def test_user_can_get_a_confirmation_token_resent(mockdata, client, session): +def test_user_can_get_a_confirmation_token_resent(client, session): with ( current_app.test_request_context(), TestCase.assertLogs(current_app.logger) as log, @@ -205,7 +203,7 @@ def test_user_can_get_a_confirmation_token_resent(mockdata, client, session): ) -def test_user_can_get_password_reset_token_sent(mockdata, client, session): +def test_user_can_get_password_reset_token_sent(client, session): with ( current_app.test_request_context(), TestCase.assertLogs(current_app.logger) as log, @@ -227,7 +225,7 @@ def test_user_can_get_password_reset_token_sent(mockdata, client, session): def test_user_can_get_password_reset_token_sent_with_differently_cased_email( - mockdata, client, session + client, session ): with ( current_app.test_request_context(), @@ -249,7 +247,7 @@ def test_user_can_get_password_reset_token_sent_with_differently_cased_email( ) -def test_user_can_get_reset_password_with_valid_token(mockdata, client, session): +def test_user_can_get_reset_password_with_valid_token(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = PasswordResetForm( @@ -267,7 +265,7 @@ def test_user_can_get_reset_password_with_valid_token(mockdata, client, session) def test_user_can_get_reset_password_with_valid_token_differently_cased( - mockdata, client, session + client, session ): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() @@ -285,7 +283,7 @@ def test_user_can_get_reset_password_with_valid_token_differently_cased( assert b"Your password has been updated." in rv.data -def test_user_cannot_reset_password_with_invalid_token(mockdata, client, session): +def test_user_cannot_reset_password_with_invalid_token(client, session): with current_app.test_request_context(): user = User.query.filter_by(is_administrator=True).first() form = PasswordResetForm( @@ -302,9 +300,7 @@ def test_user_cannot_reset_password_with_invalid_token(mockdata, client, session assert b"Your password has been updated." not in rv.data -def test_user_cannot_reset_password_multiple_times_with_same_token( - mockdata, client, session -): +def test_user_cannot_reset_password_multiple_times_with_same_token(client, session): with current_app.test_request_context(): form = PasswordResetForm( email="jen@example.org", password="catdog", password2="catdog" @@ -327,9 +323,7 @@ def test_user_cannot_reset_password_multiple_times_with_same_token( assert b"Your password has been updated." not in rv.data -def test_user_cannot_get_email_reset_token_sent_without_valid_password( - mockdata, client, session -): +def test_user_cannot_get_email_reset_token_sent_without_valid_password(client, session): with current_app.test_request_context(): login_user(client) user = User.query.filter_by(is_administrator=True).first() @@ -342,9 +336,7 @@ def test_user_cannot_get_email_reset_token_sent_without_valid_password( assert b"An email with instructions to confirm your new email" not in rv.data -def test_user_cannot_get_email_reset_token_sent_to_existing_email( - mockdata, client, session -): +def test_user_cannot_get_email_reset_token_sent_to_existing_email(client, session): with current_app.test_request_context(): login_user(client) user = User.query.filter_by(is_administrator=True).first() @@ -358,7 +350,7 @@ def test_user_cannot_get_email_reset_token_sent_to_existing_email( def test_user_cannot_get_email_reset_token_sent_to_existing_email_differently_cased( - mockdata, client, session + client, session ): with current_app.test_request_context(): login_user(client) @@ -372,9 +364,7 @@ def test_user_cannot_get_email_reset_token_sent_to_existing_email_differently_ca assert b"An email with instructions to confirm your new email" not in rv.data -def test_user_can_get_email_reset_token_sent_with_password( - mockdata, client, session, faker -): +def test_user_can_get_email_reset_token_sent_with_password(client, session, faker): with current_app.test_request_context(): login_user(client) form = ChangeEmailForm(email=faker.ascii_email(), password="dog") @@ -386,7 +376,7 @@ def test_user_can_get_email_reset_token_sent_with_password( assert b"An email with instructions to confirm your new email" in rv.data -def test_user_can_change_email_with_valid_reset_token(mockdata, client, session): +def test_user_can_change_email_with_valid_reset_token(client, session): with current_app.test_request_context(): login_user(client) user = User.query.filter_by(is_administrator=False, is_disabled=False).first() @@ -399,7 +389,7 @@ def test_user_can_change_email_with_valid_reset_token(mockdata, client, session) assert b"Your email address has been updated." in rv.data -def test_user_cannot_change_email_with_invalid_reset_token(mockdata, client, session): +def test_user_cannot_change_email_with_invalid_reset_token(client, session): with current_app.test_request_context(): login_user(client) token = "beepboopbeep" @@ -411,7 +401,7 @@ def test_user_cannot_change_email_with_invalid_reset_token(mockdata, client, ses assert b"Your email address has been updated." not in rv.data -def test_user_can_confirm_account_with_valid_token(mockdata, client, session): +def test_user_can_confirm_account_with_valid_token(client, session): with current_app.test_request_context(): login_unconfirmed_user(client) user = User.query.filter_by(confirmed=False).first() @@ -422,7 +412,7 @@ def test_user_can_confirm_account_with_valid_token(mockdata, client, session): assert b"You have confirmed your account." in rv.data -def test_user_can_not_confirm_account_with_invalid_token(mockdata, client, session): +def test_user_can_not_confirm_account_with_invalid_token(client, session): with current_app.test_request_context(): login_unconfirmed_user(client) token = "beepboopbeep" @@ -432,7 +422,7 @@ def test_user_can_not_confirm_account_with_invalid_token(mockdata, client, sessi assert b"The confirmation link is invalid or has expired." in rv.data -def test_user_can_change_password_if_they_match(mockdata, client, session): +def test_user_can_change_password_if_they_match(client, session): with ( current_app.test_request_context(), TestCase.assertLogs(current_app.logger) as log, @@ -453,7 +443,7 @@ def test_user_can_change_password_if_they_match(mockdata, client, session): ) -def test_unconfirmed_user_redirected_to_confirm_account(mockdata, client, session): +def test_unconfirmed_user_redirected_to_confirm_account(client, session): with current_app.test_request_context(): login_unconfirmed_user(client) @@ -462,13 +452,13 @@ def test_unconfirmed_user_redirected_to_confirm_account(mockdata, client, sessio assert b"Please Confirm Your Account" in rv.data -def test_disabled_user_cannot_login(mockdata, client, session): +def test_disabled_user_cannot_login(client, session): with current_app.test_request_context(): rv, _ = login_disabled_user(client) assert b"User has been disabled" in rv.data -def test_disabled_user_cannot_visit_pages_requiring_auth(mockdata, client, session): +def test_disabled_user_cannot_visit_pages_requiring_auth(client, session): # Don't use modified_disabled_user for anything else! Since we run tests # concurrently and this test modifies the user, there's a chance that # you'll get unexpected results if both tests run simultaneously. @@ -490,7 +480,7 @@ def test_disabled_user_cannot_visit_pages_requiring_auth(mockdata, client, sessi assert rv.status_code == HTTPStatus.FOUND -def test_user_cannot_change_password_if_they_dont_match(mockdata, client, session): +def test_user_cannot_change_password_if_they_dont_match(client, session): with current_app.test_request_context(): login_user(client) form = ChangePasswordForm(old_password="dog", password="cat", password2="butts") @@ -502,7 +492,7 @@ def test_user_cannot_change_password_if_they_dont_match(mockdata, client, sessio assert b"Passwords must match" in rv.data -def test_user_can_change_dept_pref(mockdata, client, session): +def test_user_can_change_dept_pref(client, session): with current_app.test_request_context(): login_user(client) form = ChangeDefaultDepartmentForm(dept_pref=AC_DEPT) @@ -517,7 +507,7 @@ def test_user_can_change_dept_pref(mockdata, client, session): assert user.dept_pref == AC_DEPT -def test_user_email_update_resets_session_token(mockdata, app, session, faker): +def test_user_email_update_resets_session_token(app, session, faker): client = current_app.test_client() with current_app.app_context(), current_app.test_request_context(): @@ -541,7 +531,7 @@ def test_user_email_update_resets_session_token(mockdata, app, session, faker): assert rv.status_code == HTTPStatus.FOUND -def test_user_password_update_resets_session_token(mockdata, app, session): +def test_user_password_update_resets_session_token(app, session): client = current_app.test_client() with current_app.app_context(), current_app.test_request_context(): diff --git a/OpenOversight/tests/routes/test_descriptions.py b/OpenOversight/tests/routes/test_descriptions.py index f19c5ec99..864290fb1 100644 --- a/OpenOversight/tests/routes/test_descriptions.py +++ b/OpenOversight/tests/routes/test_descriptions.py @@ -40,7 +40,7 @@ def test_route_admin_or_required(route, client, mockdata): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_officer_descriptions_markdown(mockdata, client, session): +def test_officer_descriptions_markdown(client, session): with current_app.test_request_context(): login_user(client) rv = client.get(url_for("main.officer_profile", officer_id=1)) @@ -50,7 +50,7 @@ def test_officer_descriptions_markdown(mockdata, client, session): assert "
A test description!
" in html -def test_admins_cannot_inject_unsafe_html(mockdata, client, session): +def test_admins_cannot_inject_unsafe_html(client, session): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() @@ -69,7 +69,7 @@ def test_admins_cannot_inject_unsafe_html(mockdata, client, session): assert "<script>" in rv.data.decode() -def test_admins_can_create_descriptions(mockdata, client, session): +def test_admins_can_create_descriptions(client, session): with current_app.test_request_context(): _, admin = login_admin(client) officer = Officer.query.first() @@ -94,7 +94,7 @@ def test_admins_can_create_descriptions(mockdata, client, session): assert created_description.last_updated_by == admin.id -def test_acs_can_create_descriptions(mockdata, client, session): +def test_acs_can_create_descriptions(client, session): with current_app.test_request_context(): _, ac = login_ac(client) officer = Officer.query.first() @@ -119,7 +119,7 @@ def test_acs_can_create_descriptions(mockdata, client, session): assert created_description.last_updated_by == ac.id -def test_admins_can_edit_descriptions(mockdata, client, session): +def test_admins_can_edit_descriptions(client, session): with current_app.test_request_context(): _, admin = login_admin(client) officer = Officer.query.first() @@ -160,7 +160,7 @@ def test_admins_can_edit_descriptions(mockdata, client, session): assert description.last_updated_by == admin.id -def test_ac_can_edit_their_descriptions_in_their_department(mockdata, client, session): +def test_ac_can_edit_their_descriptions_in_their_department(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -201,7 +201,7 @@ def test_ac_can_edit_their_descriptions_in_their_department(mockdata, client, se assert description.last_updated_by == user.id -def test_ac_can_edit_others_descriptions(mockdata, client, session): +def test_ac_can_edit_others_descriptions(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -241,7 +241,7 @@ def test_ac_can_edit_others_descriptions(mockdata, client, session): assert description.last_updated_by == user.id -def test_ac_cannot_edit_descriptions_not_in_their_department(mockdata, client, session): +def test_ac_cannot_edit_descriptions_not_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -276,7 +276,7 @@ def test_ac_cannot_edit_descriptions_not_in_their_department(mockdata, client, s assert rv.status_code == HTTPStatus.FORBIDDEN -def test_admins_can_delete_descriptions(mockdata, client, session): +def test_admins_can_delete_descriptions(client, session): with current_app.test_request_context(): login_admin(client) description = Description.query.first() @@ -294,9 +294,7 @@ def test_admins_can_delete_descriptions(mockdata, client, session): assert deleted is None -def test_acs_can_delete_their_descriptions_in_their_department( - mockdata, client, session -): +def test_acs_can_delete_their_descriptions_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -323,9 +321,7 @@ def test_acs_can_delete_their_descriptions_in_their_department( assert deleted is None -def test_acs_cannot_delete_descriptions_not_in_their_department( - mockdata, client, session -): +def test_acs_cannot_delete_descriptions_not_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -355,7 +351,7 @@ def test_acs_cannot_delete_descriptions_not_in_their_department( assert not_deleted is not None -def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): +def test_acs_can_get_edit_form_for_their_dept(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -377,7 +373,7 @@ def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): assert "Update" in rv.data.decode(ENCODING_UTF_8) -def test_acs_can_get_others_edit_form(mockdata, client, session): +def test_acs_can_get_others_edit_form(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -401,7 +397,7 @@ def test_acs_can_get_others_edit_form(mockdata, client, session): assert "Update" in rv.data.decode(ENCODING_UTF_8) -def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): +def test_acs_cannot_get_edit_form_for_their_non_dept(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -424,7 +420,7 @@ def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_users_can_see_descriptions(mockdata, client, session): +def test_users_can_see_descriptions(client, session): with current_app.test_request_context(): admin = User.query.filter_by(email=ADMIN_USER_EMAIL).first() officer = Officer.query.first() @@ -446,7 +442,7 @@ def test_users_can_see_descriptions(mockdata, client, session): assert text_contents in rv.data.decode(ENCODING_UTF_8) -def test_admins_can_see_descriptions(mockdata, client, session): +def test_admins_can_see_descriptions(client, session): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() @@ -466,7 +462,7 @@ def test_admins_can_see_descriptions(mockdata, client, session): assert text_contents in rv.data.decode(ENCODING_UTF_8) -def test_acs_can_see_descriptions_in_their_department(mockdata, client, session): +def test_acs_can_see_descriptions_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -487,7 +483,7 @@ def test_acs_can_see_descriptions_in_their_department(mockdata, client, session) assert text_contents in rv.data.decode(ENCODING_UTF_8) -def test_acs_can_see_descriptions_not_in_their_department(mockdata, client, session): +def test_acs_can_see_descriptions_not_in_their_department(client, session): with current_app.test_request_context(): officer = Officer.query.except_( Officer.query.filter_by(department_id=AC_DEPT) @@ -512,7 +508,7 @@ def test_acs_can_see_descriptions_not_in_their_department(mockdata, client, sess assert user.username in response_text -def test_anonymous_users_cannot_see_description_creators(mockdata, client, session): +def test_anonymous_users_cannot_see_description_creators(client, session): with current_app.test_request_context(): officer = Officer.query.first() ac = User.query.filter_by(ac_department_id=AC_DEPT).first() diff --git a/OpenOversight/tests/routes/test_image_tagging.py b/OpenOversight/tests/routes/test_image_tagging.py index 9b4befd4d..e66abf347 100644 --- a/OpenOversight/tests/routes/test_image_tagging.py +++ b/OpenOversight/tests/routes/test_image_tagging.py @@ -65,12 +65,12 @@ def test_invalid_department_image_sorting(client, session): "/images/classify/1/1", ], ) -def test_route_post_only(route, client, mockdata): +def test_route_post_only(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.METHOD_NOT_ALLOWED -def test_logged_in_user_can_access_sort_form(mockdata, client, session): +def test_logged_in_user_can_access_sort_form(client, session): with current_app.test_request_context(): login_user(client) @@ -90,7 +90,7 @@ def test_invalid_officer_id_display_submission(client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_user_can_view_submission(mockdata, client, session): +def test_user_can_view_submission(client, session): with current_app.test_request_context(): login_user(client) @@ -108,7 +108,7 @@ def test_invalid_tag_id_display_tag(client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_user_can_view_tag(mockdata, client, session): +def test_user_can_view_tag(client, session): with current_app.test_request_context(): login_user(client) @@ -120,7 +120,7 @@ def test_user_can_view_tag(mockdata, client, session): assert attribute in rv.data -def test_invalid_id_delete_tag(mockdata, client, session): +def test_invalid_id_delete_tag(client, session): with current_app.test_request_context(): login_admin(client) @@ -128,7 +128,7 @@ def test_invalid_id_delete_tag(mockdata, client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_admin_can_delete_tag(mockdata, client, session): +def test_admin_can_delete_tag(client, session): with current_app.test_request_context(): login_admin(client) @@ -136,7 +136,7 @@ def test_admin_can_delete_tag(mockdata, client, session): assert b"Deleted this tag" in rv.data -def test_ac_can_delete_tag_in_their_dept(mockdata, client, session): +def test_ac_can_delete_tag_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -153,7 +153,7 @@ def test_ac_can_delete_tag_in_their_dept(mockdata, client, session): assert deleted_tag is None -def test_ac_cannot_delete_tag_not_in_their_dept(mockdata, client, session): +def test_ac_cannot_delete_tag_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -179,7 +179,7 @@ def test_ac_cannot_delete_tag_not_in_their_dept(mockdata, client, session): "OpenOversight.app.utils.general.serve_image", MagicMock(return_value=PROJECT_ROOT + "/app/static/images/test_cop1.png"), ) -def test_user_can_add_tag(mockdata, client, session): +def test_user_can_add_tag(client, session): with current_app.test_request_context(): mock = MagicMock(return_value=Image.query.first()) with patch("OpenOversight.app.main.views.crop_image", mock): @@ -206,7 +206,7 @@ def test_user_can_add_tag(mockdata, client, session): assert b"Tag added to database" in rv.data -def test_user_cannot_add_tag_if_it_exists(mockdata, client, session): +def test_user_cannot_add_tag_if_it_exists(client, session): with current_app.test_request_context(): _, user = login_user(client) @@ -232,7 +232,7 @@ def test_user_cannot_add_tag_if_it_exists(mockdata, client, session): ) -def test_user_cannot_tag_nonexistent_officer(mockdata, client, session): +def test_user_cannot_tag_nonexistent_officer(client, session): with current_app.test_request_context(): _, user = login_user(client) @@ -255,7 +255,7 @@ def test_user_cannot_tag_nonexistent_officer(mockdata, client, session): assert b"Invalid officer ID" in rv.data -def test_user_cannot_tag_officer_mismatched_with_department(mockdata, client, session): +def test_user_cannot_tag_officer_mismatched_with_department(client, session): with current_app.test_request_context(): _, user = login_user(client) tag = Face.query.first() @@ -290,7 +290,7 @@ def test_invalid_id_complete_tagging(client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_complete_tagging(mockdata, client, session): +def test_complete_tagging(client, session): with current_app.test_request_context(): _, user = login_user(client) image_id = 4 @@ -304,7 +304,7 @@ def test_complete_tagging(mockdata, client, session): assert image.last_updated_by == user.id -def test_user_can_view_leaderboard(mockdata, client, session): +def test_user_can_view_leaderboard(client, session): with current_app.test_request_context(): login_user(client) @@ -312,9 +312,7 @@ def test_user_can_view_leaderboard(mockdata, client, session): assert b"Top Users by Number of Images Sorted" in rv.data -def test_user_is_redirected_to_correct_department_after_tagging( - mockdata, client, session -): +def test_user_is_redirected_to_correct_department_after_tagging(client, session): with current_app.test_request_context(): login_user(client) department_id = 2 @@ -331,7 +329,7 @@ def test_user_is_redirected_to_correct_department_after_tagging( assert department.name in rv.data.decode(ENCODING_UTF_8) -def test_invalid_id_set_featured_tag(mockdata, client, session): +def test_invalid_id_set_featured_tag(client, session): with current_app.test_request_context(): login_admin(client) @@ -341,7 +339,7 @@ def test_invalid_id_set_featured_tag(mockdata, client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_admin_can_set_featured_tag(mockdata, client, session): +def test_admin_can_set_featured_tag(client, session): with current_app.test_request_context(): login_admin(client) @@ -351,7 +349,7 @@ def test_admin_can_set_featured_tag(mockdata, client, session): assert b"Successfully set this tag as featured" in rv.data -def test_ac_can_set_featured_tag_in_their_dept(mockdata, client, session): +def test_ac_can_set_featured_tag_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -371,7 +369,7 @@ def test_ac_can_set_featured_tag_in_their_dept(mockdata, client, session): assert featured_tag is not None -def test_ac_cannot_set_featured_tag_not_in_their_dept(mockdata, client, session): +def test_ac_cannot_set_featured_tag_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -400,7 +398,7 @@ def test_ac_cannot_set_featured_tag_not_in_their_dept(mockdata, client, session) "OpenOversight.app.utils.general.serve_image", MagicMock(return_value=PROJECT_ROOT + "/app/static/images/test_cop1.png"), ) -def test_featured_tag_replaces_others(mockdata, client, session): +def test_featured_tag_replaces_others(client, session): with current_app.test_request_context(): _, user = login_admin(client) diff --git a/OpenOversight/tests/routes/test_incidents.py b/OpenOversight/tests/routes/test_incidents.py index 582e20e05..1f7703e50 100644 --- a/OpenOversight/tests/routes/test_incidents.py +++ b/OpenOversight/tests/routes/test_incidents.py @@ -35,7 +35,7 @@ def test_routes_ok(route, client, mockdata): @pytest.mark.parametrize( "route", ["incidents/1/edit", "incidents/new", "incidents/1/delete"] ) -def test_route_login_required(route, client, mockdata): +def test_route_login_required(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.FOUND @@ -59,7 +59,7 @@ def test_route_admin_or_required(route, client, mockdata): "PPP Case 92", ], ) -def test_admins_can_create_basic_incidents(report_number, mockdata, client, session): +def test_admins_can_create_basic_incidents(report_number, client, session): with current_app.test_request_context(): login_admin(client) test_date = datetime(2000, 5, 25, 1, 45) @@ -107,7 +107,7 @@ def test_admins_can_create_basic_incidents(report_number, mockdata, client, sess ], ) def test_admins_can_create_incidents_with_links( - mockdata, client, session, link_type, expected_text + client, session, link_type, expected_text ): with current_app.test_request_context(): login_admin(client) @@ -160,9 +160,7 @@ def test_admins_can_create_incidents_with_links( assert expected_text in rv.data.decode(ENCODING_UTF_8) -def test_admins_cannot_create_incident_with_invalid_report_number( - mockdata, client, session -): +def test_admins_cannot_create_incident_with_invalid_report_number(client, session): with current_app.test_request_context(): login_admin(client) test_date = datetime(2000, 5, 25, 1, 45) @@ -202,7 +200,7 @@ def test_admins_cannot_create_incident_with_invalid_report_number( ) -def test_admins_can_edit_incident_date_and_address(mockdata, client, session): +def test_admins_can_edit_incident_date_and_address(client, session): with current_app.test_request_context(): login_admin(client) inc = Incident.query.options( @@ -256,7 +254,7 @@ def test_admins_can_edit_incident_date_and_address(mockdata, client, session): assert updated.address.street_name == street_name -def test_admins_can_edit_incident_links_and_licenses(mockdata, client, session, faker): +def test_admins_can_edit_incident_links_and_licenses(client, session, faker): with current_app.test_request_context(): login_admin(client) inc = Incident.query.options( @@ -319,7 +317,7 @@ def test_admins_can_edit_incident_links_and_licenses(mockdata, client, session, assert new_number in [lp.number for lp in inc.license_plates] -def test_admins_cannot_make_ancient_incidents(mockdata, client, session): +def test_admins_cannot_make_ancient_incidents(client, session): with current_app.test_request_context(): login_admin(client) inc = Incident.query.options( @@ -359,7 +357,7 @@ def test_admins_cannot_make_ancient_incidents(mockdata, client, session): assert "Incidents prior to 1900 not allowed." in rv.data.decode(ENCODING_UTF_8) -def test_admins_cannot_make_incidents_without_state(mockdata, client, session): +def test_admins_cannot_make_incidents_without_state(client, session): with current_app.test_request_context(): login_admin(client) user = User.query.filter_by(is_administrator=True).first() @@ -396,9 +394,7 @@ def test_admins_cannot_make_incidents_without_state(mockdata, client, session): assert incident_count_before == Incident.query.count() -def test_admins_cannot_make_incidents_with_multiple_validation_errors( - mockdata, client, session -): +def test_admins_cannot_make_incidents_with_multiple_validation_errors(client, session): with current_app.test_request_context(): login_admin(client) user = User.query.filter_by(is_administrator=True).first() @@ -446,7 +442,7 @@ def test_admins_cannot_make_incidents_with_multiple_validation_errors( assert incident_count_before == Incident.query.count() -def test_admins_can_edit_incident_officers(mockdata, client, session): +def test_admins_can_edit_incident_officers(client, session): with current_app.test_request_context(): login_admin(client) user = User.query.filter_by(is_administrator=True).first() @@ -509,7 +505,7 @@ def test_admins_can_edit_incident_officers(mockdata, client, session): assert new_officer.id in [off.id for off in inc.officers] -def test_admins_cannot_edit_non_existing_officers(mockdata, client, session): +def test_admins_cannot_edit_non_existing_officers(client, session): with current_app.test_request_context(): login_admin(client) user = User.query.filter_by(is_administrator=True).first() @@ -568,7 +564,7 @@ def test_admins_cannot_edit_non_existing_officers(mockdata, client, session): assert officer in inc.officers -def test_ac_can_edit_incidents_in_their_department(mockdata, client, session): +def test_ac_can_edit_incidents_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) user = User.query.filter_by(ac_department_id=AC_DEPT).first() @@ -619,7 +615,7 @@ def test_ac_can_edit_incidents_in_their_department(mockdata, client, session): assert inc.address.street_name == street_name -def test_ac_cannot_edit_incidents_not_in_their_department(mockdata, client, session): +def test_ac_cannot_edit_incidents_not_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) user = User.query.filter_by( @@ -670,7 +666,7 @@ def test_ac_cannot_edit_incidents_not_in_their_department(mockdata, client, sess assert rv.status_code == HTTPStatus.FORBIDDEN -def test_admins_can_delete_incidents(mockdata, client, session): +def test_admins_can_delete_incidents(client, session): with current_app.test_request_context(): login_admin(client) incident = Incident.query.first() @@ -684,7 +680,7 @@ def test_admins_can_delete_incidents(mockdata, client, session): assert deleted is None -def test_acs_can_delete_incidents_in_their_department(mockdata, client, session): +def test_acs_can_delete_incidents_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) incident = Incident.query.filter_by(department_id=AC_DEPT).first() @@ -698,7 +694,7 @@ def test_acs_can_delete_incidents_in_their_department(mockdata, client, session) assert deleted is None -def test_acs_cannot_delete_incidents_not_in_their_department(mockdata, client, session): +def test_acs_cannot_delete_incidents_not_in_their_department(client, session): with current_app.test_request_context(): login_ac(client) incident = Incident.query.except_( @@ -714,7 +710,7 @@ def test_acs_cannot_delete_incidents_not_in_their_department(mockdata, client, s assert not_deleted.id is inc_id -def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): +def test_acs_can_get_edit_form_for_their_dept(client, session): with current_app.test_request_context(): login_ac(client) incident = Incident.query.filter_by(department_id=AC_DEPT).first() @@ -726,7 +722,7 @@ def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): assert "Update" in rv.data.decode(ENCODING_UTF_8) -def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): +def test_acs_cannot_get_edit_form_for_their_non_dept(client, session): with current_app.test_request_context(): login_ac(client) incident = Incident.query.except_( @@ -739,7 +735,7 @@ def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_users_can_view_incidents_by_department(mockdata, client, session): +def test_users_can_view_incidents_by_department(client, session): with current_app.test_request_context(): department = Department.query.first() department_incidents = Incident.query.filter_by(department_id=department.id) @@ -761,28 +757,28 @@ def test_users_can_view_incidents_by_department(mockdata, client, session): ) -def test_admins_can_see_who_created_incidents(mockdata, client, session): +def test_admins_can_see_who_created_incidents(client, session): with current_app.test_request_context(): login_admin(client) rv = client.get(url_for("main.incident_api", obj_id=1)) assert "Creator" in rv.data.decode(ENCODING_UTF_8) -def test_acs_cannot_see_who_created_incidents(mockdata, client, session): +def test_acs_cannot_see_who_created_incidents(client, session): with current_app.test_request_context(): login_ac(client) rv = client.get(url_for("main.incident_api", obj_id=1)) assert "Creator" not in rv.data.decode(ENCODING_UTF_8) -def test_users_cannot_see_who_created_incidents(mockdata, client, session): +def test_users_cannot_see_who_created_incidents(client, session): with current_app.test_request_context(): login_ac(client) rv = client.get(url_for("main.incident_api", obj_id=1)) assert "Creator" not in rv.data.decode(ENCODING_UTF_8) -def test_form_with_officer_id_prepopulates(mockdata, client, session): +def test_form_with_officer_id_prepopulates(client, session): with current_app.test_request_context(): login_admin(client) officer_id = "1234" @@ -790,7 +786,7 @@ def test_form_with_officer_id_prepopulates(mockdata, client, session): assert officer_id in rv.data.decode(ENCODING_UTF_8) -def test_incident_markdown(mockdata, client, session): +def test_incident_markdown(client, session): with current_app.test_request_context(): rv = client.get(url_for("main.incident_api")) html = rv.data.decode() @@ -798,7 +794,7 @@ def test_incident_markdown(mockdata, client, session): assert "Markup description
" in html -def test_admins_cannot_inject_unsafe_html(mockdata, client, session): +def test_admins_cannot_inject_unsafe_html(client, session): with current_app.test_request_context(): login_admin(client) user = User.query.filter_by(is_administrator=True).first() @@ -869,7 +865,7 @@ def test_admins_cannot_inject_unsafe_html(mockdata, client, session): ], ) def test_users_can_search_incidents( - params, included_report_nums, excluded_report_nums, mockdata, client, session + params, included_report_nums, excluded_report_nums, client, session ): with current_app.test_request_context(): rv = client.get(url_for("main.incident_api", **params)) diff --git a/OpenOversight/tests/routes/test_notes.py b/OpenOversight/tests/routes/test_notes.py index 09b5716e2..11da01208 100644 --- a/OpenOversight/tests/routes/test_notes.py +++ b/OpenOversight/tests/routes/test_notes.py @@ -35,7 +35,7 @@ def test_route_admin_or_required(route, client, mockdata): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_officer_notes_markdown(mockdata, client, session): +def test_officer_notes_markdown(client, session): with current_app.test_request_context(): login_admin(client) # need to be admin or AC to see notes rv = client.get(url_for("main.officer_profile", officer_id=1)) @@ -45,7 +45,7 @@ def test_officer_notes_markdown(mockdata, client, session): assert "A test note!
" in html -def test_admins_cannot_inject_unsafe_html(mockdata, client, session): +def test_admins_cannot_inject_unsafe_html(client, session): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() @@ -64,7 +64,7 @@ def test_admins_cannot_inject_unsafe_html(mockdata, client, session): assert "<script>" in rv.data.decode() -def test_admins_can_create_notes(mockdata, client, session, faker): +def test_admins_can_create_notes(client, session, faker): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() @@ -90,7 +90,7 @@ def test_admins_can_create_notes(mockdata, client, session, faker): assert has_database_cache_entry(*cache_params) is False -def test_acs_can_create_notes(mockdata, client, session, faker): +def test_acs_can_create_notes(client, session, faker): with current_app.test_request_context(): login_ac(client) officer = Officer.query.first() @@ -111,7 +111,7 @@ def test_acs_can_create_notes(mockdata, client, session, faker): assert created_note.created_at is not None -def test_admins_can_edit_notes(mockdata, client, session, faker): +def test_admins_can_edit_notes(client, session, faker): with current_app.test_request_context(): login_admin(client) officer = Officer.query.first() @@ -147,7 +147,7 @@ def test_admins_can_edit_notes(mockdata, client, session, faker): assert has_database_cache_entry(*cache_params) is False -def test_ac_can_edit_their_notes_in_their_department(mockdata, client, session, faker): +def test_ac_can_edit_their_notes_in_their_department(client, session, faker): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -178,7 +178,7 @@ def test_ac_can_edit_their_notes_in_their_department(mockdata, client, session, assert note.last_updated_at > original_date -def test_ac_can_edit_others_notes(mockdata, client, session): +def test_ac_can_edit_others_notes(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -212,7 +212,7 @@ def test_ac_can_edit_others_notes(mockdata, client, session): assert note.last_updated_at > original_date -def test_ac_cannot_edit_notes_not_in_their_department(mockdata, client, session): +def test_ac_cannot_edit_notes_not_in_their_department(client, session): with current_app.test_request_context(): _, user = login_ac(client) @@ -245,7 +245,7 @@ def test_ac_cannot_edit_notes_not_in_their_department(mockdata, client, session) assert rv.status_code == HTTPStatus.FORBIDDEN -def test_admins_can_delete_notes(mockdata, client, session): +def test_admins_can_delete_notes(client, session): with current_app.test_request_context(): login_admin(client) note = Note.query.first() @@ -268,7 +268,7 @@ def test_admins_can_delete_notes(mockdata, client, session): assert has_database_cache_entry(*cache_params) is False -def test_acs_can_delete_their_notes_in_their_department(mockdata, client, session): +def test_acs_can_delete_their_notes_in_their_department(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -292,9 +292,7 @@ def test_acs_can_delete_their_notes_in_their_department(mockdata, client, sessio assert deleted is None -def test_acs_cannot_delete_notes_not_in_their_department( - mockdata, client, session, faker -): +def test_acs_cannot_delete_notes_not_in_their_department(client, session, faker): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -321,7 +319,7 @@ def test_acs_cannot_delete_notes_not_in_their_department( assert not_deleted is not None -def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): +def test_acs_can_get_edit_form_for_their_dept(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -344,7 +342,7 @@ def test_acs_can_get_edit_form_for_their_dept(mockdata, client, session): assert "Update" in rv.data.decode(ENCODING_UTF_8) -def test_acs_can_get_others_edit_form(mockdata, client, session): +def test_acs_can_get_others_edit_form(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -367,7 +365,7 @@ def test_acs_can_get_others_edit_form(mockdata, client, session): assert "Update" in rv.data.decode(ENCODING_UTF_8) -def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): +def test_acs_cannot_get_edit_form_for_their_non_dept(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -391,7 +389,7 @@ def test_acs_cannot_get_edit_form_for_their_non_dept(mockdata, client, session): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_users_cannot_see_notes(mockdata, client, session, faker): +def test_users_cannot_see_notes(client, session, faker): with current_app.test_request_context(): officer = Officer.query.first() text_contents = faker.sentence(nb_words=20) @@ -416,7 +414,7 @@ def test_users_cannot_see_notes(mockdata, client, session, faker): assert text_contents not in rv.data.decode(ENCODING_UTF_8) -def test_admins_can_see_notes(mockdata, client, session): +def test_admins_can_see_notes(client, session): with current_app.test_request_context(): _, user = login_admin(client) officer = Officer.query.first() @@ -441,7 +439,7 @@ def test_admins_can_see_notes(mockdata, client, session): assert text_contents in rv.data.decode(ENCODING_UTF_8) -def test_acs_can_see_notes_in_their_department(mockdata, client, session): +def test_acs_can_see_notes_in_their_department(client, session): with current_app.test_request_context(): _, user = login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -467,7 +465,7 @@ def test_acs_can_see_notes_in_their_department(mockdata, client, session): assert text_contents in rv.data.decode(ENCODING_UTF_8) -def test_acs_cannot_see_notes_not_in_their_department(mockdata, client, session): +def test_acs_cannot_see_notes_not_in_their_department(client, session): with current_app.test_request_context(): officer = Officer.query.except_( Officer.query.filter_by(department_id=AC_DEPT) diff --git a/OpenOversight/tests/routes/test_officer_and_department.py b/OpenOversight/tests/routes/test_officer_and_department.py index 3e534d5a4..e70d3a00d 100644 --- a/OpenOversight/tests/routes/test_officer_and_department.py +++ b/OpenOversight/tests/routes/test_officer_and_department.py @@ -95,7 +95,7 @@ def test_routes_ok(route, client, mockdata): "/units/new", ], ) -def test_route_login_required(route, client, mockdata): +def test_route_login_required(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.FOUND @@ -107,18 +107,18 @@ def test_route_login_required(route, client, mockdata): "/officers/3/assignments/new", ], ) -def test_route_post_only(route, client, mockdata): +def test_route_post_only(route, client): rv = client.get(route) assert rv.status_code == HTTPStatus.METHOD_NOT_ALLOWED -def test_invalid_id_officer_profile(mockdata, client, session): +def test_invalid_id_officer_profile(client, session): with current_app.test_request_context(): rv = client.get(url_for("main.officer_profile", officer_id=400000)) assert rv.status_code == HTTPStatus.NOT_FOUND -def test_user_can_access_officer_profile(mockdata, client, session): +def test_user_can_access_officer_profile(client, session): with current_app.test_request_context(): rv = client.get( url_for("main.officer_profile", officer_id=3), follow_redirects=True @@ -132,7 +132,7 @@ def test_invalid_officer_id_officer_list(client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_user_can_access_officer_list(mockdata, client, session): +def test_user_can_access_officer_list(client, session): with current_app.test_request_context(): rv = client.get(url_for("main.list_officer", department_id=2)) @@ -149,7 +149,7 @@ def test_user_can_access_officer_list(mockdata, client, session): ], ) def test_officer_appropriately_shows_placeholder( - filter_func, has_placeholder, mockdata, client, session + filter_func, has_placeholder, client, session ): with current_app.test_request_context(): officer = Officer.query.filter(filter_func(Officer.face.any())).first() @@ -165,7 +165,7 @@ def test_officer_appropriately_shows_placeholder( assert (placeholder in rv.data.decode(ENCODING_UTF_8)) == has_placeholder -def test_ac_can_access_admin_on_dept_officer_profile(mockdata, client, session): +def test_ac_can_access_admin_on_dept_officer_profile(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -177,7 +177,7 @@ def test_ac_can_access_admin_on_dept_officer_profile(mockdata, client, session): assert "Admin only" in rv.data.decode(ENCODING_UTF_8) -def test_ac_cannot_access_admin_on_non_dept_officer_profile(mockdata, client, session): +def test_ac_cannot_access_admin_on_non_dept_officer_profile(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.except_( @@ -191,7 +191,7 @@ def test_ac_cannot_access_admin_on_non_dept_officer_profile(mockdata, client, se assert "Admin only" not in rv.data.decode(ENCODING_UTF_8) -def test_invalid_officer_id_add_assignment(mockdata, client, session): +def test_invalid_officer_id_add_assignment(client, session): with current_app.test_request_context(): login_admin(client) @@ -201,7 +201,7 @@ def test_invalid_officer_id_add_assignment(mockdata, client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_admin_can_add_assignment(mockdata, client, session): +def test_admin_can_add_assignment(client, session): with current_app.test_request_context(): login_admin(client) @@ -230,7 +230,7 @@ def test_admin_can_add_assignment(mockdata, client, session): assert assignment.resign_date == date(2019, 12, 31) -def test_admin_add_assignment_validation_error(mockdata, client, session): +def test_admin_add_assignment_validation_error(client, session): with current_app.test_request_context(): login_admin(client) officer = session.get(Officer, 3) @@ -255,7 +255,7 @@ def test_admin_add_assignment_validation_error(mockdata, client, session): assert assignments is None -def test_ac_can_add_assignment_in_their_dept(mockdata, client, session): +def test_ac_can_add_assignment_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) officer = Officer.query.filter_by(department_id=AC_DEPT).first() @@ -287,7 +287,7 @@ def test_ac_can_add_assignment_in_their_dept(mockdata, client, session): assert assignment.resign_date == date(2019, 12, 31) -def test_ac_cannot_add_non_dept_assignment(mockdata, client, session): +def test_ac_cannot_add_non_dept_assignment(client, session): with current_app.test_request_context(): login_ac(client) @@ -320,7 +320,7 @@ def test_invalid_officer_id_edit_assignment(client, session): assert rv.status_code == HTTPStatus.NOT_FOUND -def test_admin_can_edit_assignment(mockdata, client, session): +def test_admin_can_edit_assignment(client, session): with current_app.test_request_context(): login_admin(client) @@ -382,7 +382,7 @@ def test_admin_can_edit_assignment(mockdata, client, session): def test_admin_edit_assignment_validation_error( - mockdata, client, session, officer_no_assignments + client, session, officer_no_assignments ): with current_app.test_request_context(): login_admin(client) @@ -423,7 +423,7 @@ def test_admin_edit_assignment_validation_error( assert assignment.resign_date == date(2019, 12, 31) -def test_ac_can_edit_officer_in_their_dept_assignment(mockdata, client, session): +def test_ac_can_edit_officer_in_their_dept_assignment(client, session): with current_app.test_request_context(): login_ac(client) @@ -486,7 +486,7 @@ def test_ac_can_edit_officer_in_their_dept_assignment(mockdata, client, session) assert officer.assignments[0].resign_date == date(2019, 11, 30) -def test_ac_cannot_edit_assignment_outside_their_dept(mockdata, client, session): +def test_ac_cannot_edit_assignment_outside_their_dept(client, session): with current_app.test_request_context(): login_admin(client) @@ -536,7 +536,7 @@ def test_ac_cannot_edit_assignment_outside_their_dept(mockdata, client, session) TestPD = PoliceDepartment("Test Police Department", "TPD") -def test_admin_can_add_police_department(mockdata, client, session): +def test_admin_can_add_police_department(client, session): with current_app.test_request_context(): _, user = login_admin(client) @@ -563,7 +563,7 @@ def test_admin_can_add_police_department(mockdata, client, session): assert department.last_updated_by == user.id -def test_admin_cannot_add_police_department_without_state(mockdata, client, session): +def test_admin_cannot_add_police_department_without_state(client, session): with current_app.test_request_context(): login_admin(client) @@ -576,7 +576,7 @@ def test_admin_cannot_add_police_department_without_state(mockdata, client, sess assert "Invalid value, must be one of: FA, AL, AK, AZ" in errors.get("state")[0] -def test_ac_cannot_add_police_department(mockdata, client, session): +def test_ac_cannot_add_police_department(client, session): with current_app.test_request_context(): login_ac(client) @@ -593,7 +593,7 @@ def test_ac_cannot_add_police_department(mockdata, client, session): assert rv.status_code == HTTPStatus.FORBIDDEN -def test_admin_cannot_add_duplicate_police_department(mockdata, client, session): +def test_admin_cannot_add_duplicate_police_department(client, session): with current_app.test_request_context(): login_admin(client) @@ -629,7 +629,7 @@ def test_admin_cannot_add_duplicate_police_department(mockdata, client, session) CorrectedPD = PoliceDepartment("Corrected Police Department", "CPD") -def test_admin_can_edit_police_department(mockdata, client, session): +def test_admin_can_edit_police_department(client, session): with current_app.test_request_context(): # Prevent CorrectedPD and MisspelledPD from having the same state MisspelledPD = PoliceDepartment( @@ -740,7 +740,7 @@ def test_admin_can_edit_police_department(mockdata, client, session): ) -def test_admin_cannot_edit_police_department_without_state(mockdata, client, session): +def test_admin_cannot_edit_police_department_without_state(client, session): with current_app.test_request_context(): login_admin(client) @@ -773,7 +773,7 @@ def test_admin_cannot_edit_police_department_without_state(mockdata, client, ses assert "Invalid value, must be one of: FA, AL, AK, AZ" in errors.get("state")[0] -def test_ac_cannot_edit_police_department(mockdata, client, session, department): +def test_ac_cannot_edit_police_department(client, session, department): with current_app.test_request_context(): login_ac(client) @@ -792,7 +792,7 @@ def test_ac_cannot_edit_police_department(mockdata, client, session, department) assert rv.status_code == HTTPStatus.FORBIDDEN -def test_admin_can_edit_rank_order(mockdata, client, session, department): +def test_admin_can_edit_rank_order(client, session, department): with current_app.test_request_context(): login_admin(client) ranks = department.jobs @@ -826,7 +826,7 @@ def test_admin_can_edit_rank_order(mockdata, client, session, department): ) -def test_admin_cannot_delete_rank_in_use(mockdata, client, session, department): +def test_admin_cannot_delete_rank_in_use(client, session, department): with current_app.test_request_context(): login_admin(client) @@ -856,7 +856,7 @@ def test_admin_cannot_delete_rank_in_use(mockdata, client, session, department): assert len(updated_ranks) == len(original_ranks) -def test_admin_can_delete_rank_not_in_use(mockdata, client, session, department): +def test_admin_can_delete_rank_not_in_use(client, session, department): with current_app.test_request_context(): login_admin(client) ranks_update = RANK_CHOICES_1.copy() @@ -919,9 +919,7 @@ def test_admin_can_delete_rank_not_in_use(mockdata, client, session, department) ) -def test_admin_can_delete_multiple_ranks_not_in_use( - mockdata, client, session, department -): +def test_admin_can_delete_multiple_ranks_not_in_use(client, session, department): with current_app.test_request_context(): login_admin(client) @@ -980,7 +978,7 @@ def test_admin_can_delete_multiple_ranks_not_in_use( def test_admin_cannot_commit_edit_that_deletes_one_rank_in_use_and_one_not_in_use_rank( - mockdata, client, session, department + client, session, department ): with current_app.test_request_context(): login_admin(client) @@ -1047,9 +1045,7 @@ def test_admin_cannot_commit_edit_that_deletes_one_rank_in_use_and_one_not_in_us ExistingPD = PoliceDepartment("Existing Police Department", "EPD") -def test_admin_can_create_department_with_same_name_in_different_state( - mockdata, client, session -): +def test_admin_can_create_department_with_same_name_in_different_state(client, session): with current_app.test_request_context(): login_admin(client) @@ -1122,9 +1118,7 @@ def test_admin_can_create_department_with_same_name_in_different_state( ) in existing_duplicate_rv.data.decode(ENCODING_UTF_8) -def test_admin_cannot_duplicate_police_department_during_edit( - mockdata, client, session -): +def test_admin_cannot_duplicate_police_department_during_edit(client, session): with current_app.test_request_context(): login_admin(client) @@ -1188,7 +1182,7 @@ def test_admin_cannot_duplicate_police_department_during_edit( assert new_department.short_name == NewPD.short_name -def test_expected_dept_appears_in_submission_dept_selection(mockdata, client, session): +def test_expected_dept_appears_in_submission_dept_selection(client, session): with current_app.test_request_context(): login_admin(client) @@ -1197,7 +1191,7 @@ def test_expected_dept_appears_in_submission_dept_selection(mockdata, client, se assert SPRINGFIELD_PD.name in rv.data.decode(ENCODING_UTF_8) -def test_admin_can_add_new_officer(mockdata, client, session, department, faker): +def test_admin_can_add_new_officer(client, session, department, faker): with current_app.test_request_context(): _, admin = login_admin(client) @@ -1258,9 +1252,7 @@ def test_admin_can_add_new_officer(mockdata, client, session, department, faker) assert officer.descriptions[0].last_updated_by == admin.id -def test_admin_can_add_new_officer_with_unit( - mockdata, client, session, department, faker -): +def test_admin_can_add_new_officer_with_unit(client, session, department, faker): with current_app.test_request_context(): login_admin(client) @@ -1298,7 +1290,7 @@ def test_admin_can_add_new_officer_with_unit( assert Assignment.query.filter_by(base_officer=officer, unit=unit).one() -def test_ac_can_add_new_officer_in_their_dept(mockdata, client, session): +def test_ac_can_add_new_officer_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) department = session.get(Department, AC_DEPT) @@ -1340,7 +1332,7 @@ def test_ac_can_add_new_officer_in_their_dept(mockdata, client, session): assert officer.gender == gender -def test_ac_can_add_new_officer_with_unit_in_their_dept(mockdata, client, session): +def test_ac_can_add_new_officer_with_unit_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) department = session.get(Department, AC_DEPT) @@ -1385,7 +1377,7 @@ def test_ac_can_add_new_officer_with_unit_in_their_dept(mockdata, client, sessio assert Assignment.query.filter_by(base_officer=officer, unit=unit).one() -def test_ac_cannot_add_new_officer_not_in_their_dept(mockdata, client, session): +def test_ac_cannot_add_new_officer_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -1418,7 +1410,7 @@ def test_ac_cannot_add_new_officer_not_in_their_dept(mockdata, client, session): assert officer is None -def test_admin_can_edit_existing_officer(mockdata, client, session, department, faker): +def test_admin_can_edit_existing_officer(client, session, department, faker): with current_app.test_request_context(): login_admin(client) @@ -1464,7 +1456,7 @@ def test_admin_can_edit_existing_officer(mockdata, client, session, department, assert link_url1 not in rv.data.decode(ENCODING_UTF_8) -def test_ac_cannot_edit_officer_not_in_their_dept(mockdata, client, session): +def test_ac_cannot_edit_officer_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -1491,7 +1483,7 @@ def test_ac_cannot_edit_officer_not_in_their_dept(mockdata, client, session): assert officer.last_name == old_last_name -def test_ac_can_see_officer_not_in_their_dept(mockdata, client, session): +def test_ac_can_see_officer_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -1509,7 +1501,7 @@ def test_ac_can_see_officer_not_in_their_dept(mockdata, client, session): assert str(officer.id) in rv.data.decode(ENCODING_UTF_8) -def test_ac_can_edit_officer_in_their_dept(mockdata, client, session): +def test_ac_can_edit_officer_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) department = session.get(Department, AC_DEPT) @@ -1566,9 +1558,7 @@ def test_ac_can_edit_officer_in_their_dept(mockdata, client, session): assert officer.last_name == new_last_name -def test_admin_adds_officer_without_middle_initial( - mockdata, client, session, department -): +def test_admin_adds_officer_without_middle_initial(client, session, department): with current_app.test_request_context(): login_admin(client) @@ -1597,9 +1587,7 @@ def test_admin_adds_officer_without_middle_initial( assert officer.gender == "M" -def test_admin_adds_officer_with_letter_in_badge_no( - mockdata, client, session, department -): +def test_admin_adds_officer_with_letter_in_badge_no(client, session, department): with current_app.test_request_context(): login_admin(client) @@ -1629,7 +1617,7 @@ def test_admin_adds_officer_with_letter_in_badge_no( assert officer.assignments[0].star_no == "T666" -def test_admin_can_add_new_unit(mockdata, client, session, department): +def test_admin_can_add_new_unit(client, session, department): with current_app.test_request_context(): login_admin(client) @@ -1646,7 +1634,7 @@ def test_admin_can_add_new_unit(mockdata, client, session, department): assert unit.department_id == department.id -def test_ac_can_add_new_unit_in_their_dept(mockdata, client, session): +def test_ac_can_add_new_unit_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -1664,7 +1652,7 @@ def test_ac_can_add_new_unit_in_their_dept(mockdata, client, session): assert unit.department_id == department.id -def test_ac_cannot_add_new_unit_not_in_their_dept(mockdata, client, session): +def test_ac_cannot_add_new_unit_not_in_their_dept(client, session): with current_app.test_request_context(): login_ac(client) @@ -1680,9 +1668,7 @@ def test_ac_cannot_add_new_unit_not_in_their_dept(mockdata, client, session): assert unit is None -def test_admin_can_add_new_officer_with_suffix( - mockdata, client, session, department, faker -): +def test_admin_can_add_new_officer_with_suffix(client, session, department, faker): with current_app.test_request_context(): login_admin(client) @@ -1728,9 +1714,7 @@ def test_invalid_officer_id_upload_photos(client, session): assert "This officer does not exist." in rv.data.decode(ENCODING_UTF_8) -def test_ac_cannot_directly_upload_photos_of_of_non_dept_officers( - mockdata, client, session -): +def test_ac_cannot_directly_upload_photos_of_of_non_dept_officers(client, session): with current_app.test_request_context(): login_ac(client) department = Department.query.except_( @@ -1746,7 +1730,7 @@ def test_ac_cannot_directly_upload_photos_of_of_non_dept_officers( assert rv.status_code == HTTPStatus.FORBIDDEN -def test_officer_csv(mockdata, client, session, department, faker): +def test_officer_csv(client, session, department, faker): with current_app.test_request_context(): login_admin(client) links = [ @@ -1795,7 +1779,7 @@ def test_officer_csv(mockdata, client, session, department, faker): assert form.star_no.data == added_lines[0]["badge number"] -def test_assignments_csv(mockdata, client, session, department): +def test_assignments_csv(client, session, department): with current_app.test_request_context(): _, user = login_admin(client) officer = Officer.query.filter_by(department_id=department.id).first() @@ -1835,7 +1819,7 @@ def test_assignments_csv(mockdata, client, session, department): assert new_assignment[0]["job title"] == job.job_title -def test_incidents_csv(mockdata, client, session, department, faker): +def test_incidents_csv(client, session, department, faker): with current_app.test_request_context(): login_admin(client) @@ -1884,7 +1868,7 @@ def test_incidents_csv(mockdata, client, session, department, faker): assert form.description.data in csv[0] -def test_browse_filtering_filters_bad(client, mockdata, session): +def test_browse_filtering_filters_bad(client, session): with current_app.test_request_context(): race_list = ["BLACK", "WHITE"] gender_list = ["M", "F"] @@ -1937,7 +1921,7 @@ def test_browse_filtering_filters_bad(client, mockdata, session): assert not any(bad_substr in token for token in filter_list) -def test_browse_filtering_allows_good(client, mockdata, session, faker): +def test_browse_filtering_allows_good(client, session, faker): with current_app.test_request_context(): department_id = Department.query.first().id @@ -2018,7 +2002,7 @@ def normalize_tokens_for_comparison(html_str: TestResponse, split_str: str): assert any("