Skip to content

Commit

Permalink
chore(backend): linted
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Oct 18, 2024
1 parent 1198483 commit 21d4407
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions backend/timed/employment/tests/test_employment.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_employment_list_supervisor(auth_client):
assert len(json["data"]) == 2


@pytest.mark.django_db()
@pytest.mark.django_db
def test_employment_unique_active():
"""Should only be able to have one active employment per user."""
user = UserFactory.create()
Expand All @@ -148,7 +148,7 @@ def test_employment_unique_active():
form.save()


@pytest.mark.django_db()
@pytest.mark.django_db
def test_employment_start_before_end():
employment = EmploymentFactory.create()
form = EmploymentForm(
Expand All @@ -160,7 +160,7 @@ def test_employment_start_before_end():
form.save()


@pytest.mark.django_db()
@pytest.mark.django_db
def test_employment_get_at():
"""Should return the right employment on a date."""
user = UserFactory.create()
Expand All @@ -176,7 +176,7 @@ def test_employment_get_at():
Employment.objects.get_at(user, employment.start_date + timedelta(days=21))


@pytest.mark.django_db()
@pytest.mark.django_db
def test_worktime_balance_partial():
"""
Test partial calculation of worktime balance.
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_worktime_balance_partial():
assert balance == expected_balance


@pytest.mark.django_db()
@pytest.mark.django_db
def test_worktime_balance_longer():
"""Test calculation of worktime when frame is longer than employment."""
employment = factories.EmploymentFactory.create(
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_worktime_balance_longer():
assert balance == expected_balance


@pytest.mark.django_db()
@pytest.mark.django_db
def test_employment_for_user():
user = factories.UserFactory.create()
# employment overlapping time frame (early start)
Expand Down
2 changes: 1 addition & 1 deletion backend/timed/employment/tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from timed.employment.factories import EmploymentFactory, LocationFactory


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("location")
@pytest.mark.parametrize(
("is_employed", "is_customer_assignee", "is_customer", "expected"),
Expand Down
6 changes: 3 additions & 3 deletions backend/timed/employment/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def test_user_list_unauthenticated(client):
assert response.status_code == status.HTTP_401_UNAUTHORIZED


@pytest.mark.django_db()
@pytest.mark.django_db
def test_user_update_unauthenticated(client):
user = UserFactory.create()
url = reverse("user-detail", args=[user.id])
response = client.patch(url)
assert response.status_code == status.HTTP_401_UNAUTHORIZED


@pytest.mark.django_db()
@pytest.mark.django_db
def test_user_list(internal_employee_client, django_assert_num_queries):
UserFactory.create_batch(2)

Expand Down Expand Up @@ -146,7 +146,7 @@ def test_user_delete_superuser(superadmin_client):
assert response.status_code == status.HTTP_204_NO_CONTENT


@pytest.mark.django_db()
@pytest.mark.django_db
def test_user_delete_with_reports_superuser(superadmin_client):
"""Test that user with reports may not be deleted."""
user = UserFactory.create()
Expand Down
8 changes: 4 additions & 4 deletions backend/timed/notifications/tests/test_budget_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from timed.redmine.models import RedmineProject


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("duration", "percentage_exceeded", "notification_count"),
[(1, 0, 0), (3, 0, 0), (4, 30, 1), (8, 70, 2), (0, 0, 0)],
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_budget_check_1(
assert Notification.objects.all().count() == notification_count


@pytest.mark.django_db()
@pytest.mark.django_db
def test_budget_check_skip_notification(capsys, mocker, report_factory):
redmine_instance = mocker.MagicMock()
issue = mocker.MagicMock()
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_budget_check_skip_notification(capsys, mocker, report_factory):
)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_budget_check_no_estimated_timed(mocker, report_factory):
redmine_instance = mocker.MagicMock()
issue = mocker.MagicMock()
Expand All @@ -107,7 +107,7 @@ def test_budget_check_no_estimated_timed(mocker, report_factory):
assert Notification.objects.count() == 0


@pytest.mark.django_db()
@pytest.mark.django_db
def test_budget_check_invalid_issue(mocker, capsys, report_factory):
redmine_instance = mocker.MagicMock()
redmine_class = mocker.patch("redminelib.Redmine")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from timed.notifications.models import Notification


@pytest.mark.django_db()
@pytest.mark.django_db
def test_notify_changed_employments(mailoutbox, freezer):
email = "[email protected]"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from timed.tracking.factories import ReportFactory


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.freeze_time("2017-8-4")
@pytest.mark.parametrize(
("cc", "message"),
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_notify_reviewers_with_cc_and_message(mailoutbox, cc, message):
assert mail.cc[0] == cc


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.freeze_time("2017-8-4")
def test_notify_reviewers(mailoutbox):
"""Test time range 2017-7-1 till 2017-7-31."""
Expand All @@ -93,7 +93,7 @@ def test_notify_reviewers(mailoutbox):
assert Notification.objects.count() == 1


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.freeze_time("2017-8-4")
def test_notify_reviewers_reviewer_hierarchy(mailoutbox):
"""Test notification with reviewer hierarchy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from timed.tracking.factories import ReportFactory


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.freeze_time("2017-7-27")
def test_notify_supervisors(mailoutbox):
"""Test time range 2017-7-17 till 2017-7-23."""
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_notify_supervisors(mailoutbox):
assert Notification.objects.count() == 1


@pytest.mark.django_db()
@pytest.mark.django_db
def test_notify_supervisors_no_employment(mailoutbox):
"""Check that supervisees without employment do not notify supervisor."""
supervisee = UserFactory.create()
Expand Down
2 changes: 1 addition & 1 deletion backend/timed/projects/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_project_list_include(
assert json["data"][0]["id"] == str(project.id)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_project_detail_no_auth(client, project):
url = reverse("project-detail", args=[project.id])

Expand Down
8 changes: 4 additions & 4 deletions backend/timed/redmine/tests/test_redmine_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from timed.redmine.models import RedmineProject


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize("not_billable", [False, True])
@pytest.mark.parametrize("review", [False, True])
def test_redmine_report(freezer, mocker, report_factory, not_billable, review):
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_redmine_report(freezer, mocker, report_factory, not_billable, review):
issue.save.assert_called_once_with()


@pytest.mark.django_db()
@pytest.mark.django_db
def test_redmine_report_no_estimated_time(freezer, mocker, task, report_factory):
redmine_instance = mocker.MagicMock()
issue = mocker.MagicMock()
Expand All @@ -69,7 +69,7 @@ def test_redmine_report_no_estimated_time(freezer, mocker, task, report_factory)
issue.save.assert_called_once_with()


@pytest.mark.django_db()
@pytest.mark.django_db
def test_redmine_report_invalid_issue(freezer, mocker, capsys, report_factory):
"""Test case when issue is not available."""
redmine_instance = mocker.MagicMock()
Expand All @@ -88,7 +88,7 @@ def test_redmine_report_invalid_issue(freezer, mocker, capsys, report_factory):
assert "issue 1000 assigned" in err


@pytest.mark.django_db()
@pytest.mark.django_db
def test_redmine_report_calculate_total_hours(freezer, mocker, task, report_factory):
redmine_instance = mocker.MagicMock()
issue = mocker.MagicMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from timed.redmine.models import RedmineProject


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize("pretend", [True, False])
@pytest.mark.parametrize("amount_offered", [None, 100.00, 0])
def test_update_project_expenditure(
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_update_project_expenditure(
assert f"amount invoiced {project.amount_invoiced.amount}" in out


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("freezer")
def test_update_project_expenditure_invalid_issue(mocker, capsys, report_factory):
redmine_instance = mocker.MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion backend/timed/reports/tests/test_work_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_work_report_empty(auth_client):


@pytest.mark.freeze_time("2017-08-18")
@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("customer_name", "project_name", "expected"),
[
Expand Down
14 changes: 7 additions & 7 deletions backend/timed/tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from timed.employment.factories import UserFactory


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize("is_id_token", [True, False])
@pytest.mark.parametrize(
("authentication_header", "error"),
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_authentication(
)


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("create_user", "username", "expected_count"),
[(False, "", 0), (True, "", 1), (True, "[email protected]", 1)],
Expand All @@ -90,7 +90,7 @@ def test_authentication_new_user(
assert user_model.objects.count() == expected_count


@pytest.mark.django_db()
@pytest.mark.django_db
def test_authentication_update_user_data(rf, requests_mock, settings):
user_model = get_user_model()
user = UserFactory.create()
Expand All @@ -114,7 +114,7 @@ def test_authentication_update_user_data(rf, requests_mock, settings):
assert user.email == "test@localhost"


@pytest.mark.django_db()
@pytest.mark.django_db
def test_authentication_idp_502(rf, requests_mock, settings):
requests_mock.get(
settings.OIDC_OP_USER_ENDPOINT, status_code=status.HTTP_502_BAD_GATEWAY
Expand All @@ -125,7 +125,7 @@ def test_authentication_idp_502(rf, requests_mock, settings):
OIDCAuthentication().authenticate(request)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_authentication_idp_missing_claim(rf, requests_mock, settings):
settings.OIDC_USERNAME_CLAIM = "missing"
userinfo = {"preferred_username": "1"}
Expand All @@ -136,7 +136,7 @@ def test_authentication_idp_missing_claim(rf, requests_mock, settings):
OIDCAuthentication().authenticate(request)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_authentication_no_client(rf, requests_mock, settings):
requests_mock.get(
settings.OIDC_OP_USER_ENDPOINT, status_code=status.HTTP_401_UNAUTHORIZED
Expand All @@ -151,7 +151,7 @@ def test_authentication_no_client(rf, requests_mock, settings):
OIDCAuthentication().authenticate(request)


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize("check_introspect", [True, False])
def test_userinfo_introspection_failure(
client, rf, requests_mock, settings, check_introspect
Expand Down
4 changes: 2 additions & 2 deletions backend/timed/tracking/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ def test_report_delete_not_report_owner(
]


@pytest.mark.django_db()
@pytest.mark.django_db
def test_report_round_duration(report_factory):
"""Should round the duration of a report to 15 minutes."""
report = report_factory.create()
Expand Down Expand Up @@ -1439,7 +1439,7 @@ def test_report_notify_rendering(
snapshot.assert_match(mailoutbox[0].body)


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("project", "task")
@pytest.mark.parametrize(
("report__review", "needs_review"), [(True, False), (False, True), (True, True)]
Expand Down

0 comments on commit 21d4407

Please sign in to comment.