Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 15, 2024
1 parent a9f974f commit c943a30
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 108 deletions.
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _debug(settings: SettingsWrapper) -> None:
template["OPTIONS"]["debug"] = True


@pytest.fixture()
@pytest.fixture

Check failure on line 43 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:43:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`

Check failure on line 43 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:43:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`
def main_heading() -> str:
"""An example fixture containing some html fragment."""
return '<p class="mt-2 text-sm text-base-content text-opacity-80">Report, manage, escalate!</p>'
Expand Down Expand Up @@ -76,13 +76,13 @@ def django_db_setup( # noqa: PT004
django_db_blocker.restore()


@pytest.fixture()
@pytest.fixture

Check failure on line 79 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:79:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`

Check failure on line 79 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:79:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`
def incident() -> Incident:
return IncidentFactory.build()


@pytest.fixture()
@pytest.mark.django_db()
@pytest.fixture

Check failure on line 84 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:84:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`

Check failure on line 84 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT001)

tests/conftest.py:84:1: PT001 Use `@pytest.fixture()` over `@pytest.fixture`
@pytest.mark.django_db

Check failure on line 85 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/conftest.py:85:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 85 in tests/conftest.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/conftest.py:85:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def incident_saved() -> Incident:
incident: Incident = IncidentFactory.build()
incident.component.group.save()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api/test_api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_api_schema(client: Client) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 25 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:25:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 25 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:25:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_incidents_cost_api(admin_client: Client, admin_user: User) -> None:
"""This test ensures that the incidents costs API endpoint is accessible for an admin"""
admin_client.force_login(admin_user)
Expand All @@ -31,7 +31,7 @@ def test_incidents_cost_api(admin_client: Client, admin_user: User) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 34 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:34:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 34 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:34:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_incidents_cost_api_unauthorized(client: Client) -> None:
"""This test ensures that the incidents costs API endpoint is not accessible for a guest user"""
user = UserFactory.create()
Expand All @@ -41,7 +41,7 @@ def test_incidents_cost_api_unauthorized(client: Client) -> None:
assert response.status_code == 403


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 44 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:44:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 44 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:44:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_incidents_cost_type_api(admin_client: Client, admin_user: User) -> None:
"""This test ensures that the incidents cost types API endpoint is accessible for an admin"""
admin_client.force_login(admin_user)
Expand All @@ -50,7 +50,7 @@ def test_incidents_cost_type_api(admin_client: Client, admin_user: User) -> None
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 53 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:53:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 53 in tests/test_api/test_api_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_api/test_api_urls.py:53:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_incidents_cost_api_type_unauthorized(client: Client) -> None:
"""This test ensures that the incidents costs API endpoint is not accessible for a guest user"""
user = UserFactory.create()
Expand Down
24 changes: 12 additions & 12 deletions tests/test_firefighter/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
logger = logging.getLogger(__name__)


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 20 in tests/test_firefighter/test_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_firefighter/test_urls.py:20:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 20 in tests/test_firefighter/test_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_firefighter/test_urls.py:20:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_health_check(client: Client) -> None:
"""This test ensures that health check is accessible."""
response = client.get("/api/v2/firefighter/monitoring/healthcheck")

assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db

Check failure on line 28 in tests/test_firefighter/test_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (PT023)

tests/test_firefighter/test_urls.py:28:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`

Check failure on line 28 in tests/test_firefighter/test_urls.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.12, ubuntu-latest)

Ruff (PT023)

tests/test_firefighter/test_urls.py:28:1: PT023 Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
def test_admin_unauthorized(client: Client) -> None:
"""This test ensures that admin panel requires auth."""
response = client.get("/admin/")

assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_admin_authorized(admin_client: Client, admin_user: User) -> None:
"""This test ensures that admin panel is accessible."""
Expand All @@ -44,7 +44,7 @@ def test_admin_authorized(admin_client: Client, admin_user: User) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_admin_docs_unauthorized(client: Client) -> None:
"""This test ensures that admin panel docs requires auth."""
response = client.get("/admin/doc/")
Expand All @@ -54,7 +54,7 @@ def test_admin_docs_unauthorized(client: Client) -> None:
assert response.url == "/admin/login/?next=/admin/doc/"


@pytest.mark.django_db()
@pytest.mark.django_db
def test_admin_docs_authorized(admin_client: Client) -> None:
"""This test ensures that admin panel docs are accessible."""
response = admin_client.get("/admin/doc/")
Expand All @@ -63,7 +63,7 @@ def test_admin_docs_authorized(admin_client: Client) -> None:
assert b"docutils" not in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_robotstxt_present(client: Client) -> None:
"""This test ensures that robots.txt is present."""
response = client.get("/robots.txt")
Expand All @@ -72,7 +72,7 @@ def test_robotstxt_present(client: Client) -> None:
assert b"Disallow: /" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_login_sso_button_admin_login(client: Client) -> None:
"""This test ensures that login page contains the SSO button."""
response = client.get("/admin/login/")
Expand All @@ -81,7 +81,7 @@ def test_login_sso_button_admin_login(client: Client) -> None:
assert b"Log in with SSO" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_500_pretty(client: Client) -> None:
"""This test ensures that 500 error page is pretty."""
with pytest.raises(Exception, match="Test exception for 500"): # noqa: PT012
Expand All @@ -91,7 +91,7 @@ def test_error_500_pretty(client: Client) -> None:
assert b"Please try again later, and report it" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_404_pretty(client: Client) -> None:
"""This test ensures that 404 error page is pretty."""
response = client.get("/err/404/")
Expand All @@ -100,7 +100,7 @@ def test_error_404_pretty(client: Client) -> None:
assert b"Please check the URL in the address bar and try again" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_403_pretty(client: Client) -> None:
"""This test ensures that 403 error page is pretty."""
response = client.get("/err/403/")
Expand All @@ -109,7 +109,7 @@ def test_error_403_pretty(client: Client) -> None:
assert b"You do not have permission to access this page." in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_400_pretty(client: Client) -> None:
"""This test ensures that 400 error page is pretty."""
response = client.get("/err/400/")
Expand All @@ -129,7 +129,7 @@ def test_errors_json(client: Client) -> None:
assert json.loads(response.content).get("error") is not None


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.timeout(30)
@pytest.mark.usefixtures("_debug")
def test_all_admin_list_no_error(admin_client: Client, admin_user: User) -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_incidents/test_forms/test_form_select_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from firefighter.incidents.forms.select_impact import SelectImpactForm


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("form_data", "expected_priority"),
[
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_suggest_priority_from_impact(form_data, expected_priority):
assert priority == expected_priority


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("form_data", "expected_priority"),
[
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_suggest_priority_from_impact(form_data, expected_priority):
),
],
)
@pytest.mark.django_db()
@pytest.mark.django_db
def test_suggest_priority_from_impact_with_invalid_form(form_data, expected_priority):
form = SelectImpactForm(data=form_data)
assert not form.is_valid()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_incidents/test_forms/test_form_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class GroupedModelChoiceFieldForm(Form):
)


@pytest.fixture()
@pytest.fixture
def group() -> Group:
return Group.objects.create(name="Group 1")


@pytest.fixture()
@pytest.fixture
def components(group: Group):
return [
Component.objects.create(name="Component 1", group=group, order=1),
Expand All @@ -46,7 +46,7 @@ def test_enum_choice_field_invalid() -> None:
assert "status" in form.errors


@pytest.mark.django_db()
@pytest.mark.django_db
def test_grouped_model_choice_field_valid(components: list[Component]):
form = GroupedModelChoiceFieldForm({"component": components[0].id})
assert form.is_valid()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_incidents/test_forms/test_update_key_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from firefighter.incidents.models.milestone_type import MilestoneType


@pytest.fixture()
@pytest.fixture
def user() -> User:
return User.objects.create_user(username="testuser")


@pytest.fixture()
@pytest.fixture
def milestone_type() -> MilestoneType:
return MilestoneType(
event_type="detected",
Expand All @@ -26,7 +26,7 @@ def milestone_type() -> MilestoneType:
)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incident_update_key_events_form(
user: User, incident_saved: Incident, milestone_type: MilestoneType
):
Expand Down
20 changes: 10 additions & 10 deletions tests/test_incidents/test_incident_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
logger = logging.getLogger(__name__)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_dashboard_unauthorized(client: Client) -> None:
"""This test ensures that the incidents dashboard is not accessible, and that we are redirect to auth."""
response = client.get(reverse("incidents:dashboard"))

assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_list_unauthorized(client: Client) -> None:
"""This test ensures that the incidents page list is accessible."""
response = client.get(reverse("incidents:incident-list"))

assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incidents_statistics_unauthorized(client: Client) -> None:
"""This test ensures that the incidents statistics page is accessible."""
Expand All @@ -41,7 +41,7 @@ def test_incidents_statistics_unauthorized(client: Client) -> None:
assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incidents_dashboard_authorized(admin_client: Client, admin_user: User) -> None:
"""This test ensures that the incidents dashboard is accessible for an admin."""
Expand All @@ -51,7 +51,7 @@ def test_incidents_dashboard_authorized(admin_client: Client, admin_user: User)
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incidents_details(client: Client, admin_user: User) -> None:
"""This test ensures that the incidents dashboard is accessible for an admin."""
Expand All @@ -65,7 +65,7 @@ def test_incidents_details(client: Client, admin_user: User) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incidents_details_unauthorized_404_redirect(client: Client) -> None:
"""This test ensures that the incidents dashboard will return a 404."""
Expand All @@ -76,7 +76,7 @@ def test_incidents_details_unauthorized_404_redirect(client: Client) -> None:
assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incidents_details_authorized_404(client: Client, admin_user: User) -> None:
"""This test ensures that the incidents dashboard will return a 404."""
Expand All @@ -88,7 +88,7 @@ def test_incidents_details_authorized_404(client: Client, admin_user: User) -> N
assert response.status_code == 404


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incident_create_unauthorized(client: Client) -> None:
"""This test ensures that the incident create page is accessible."""
Expand All @@ -98,7 +98,7 @@ def test_incident_create_unauthorized(client: Client) -> None:
assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_component_list(client: Client) -> None:
"""This test ensures that the component list is accessible."""
Expand All @@ -107,7 +107,7 @@ def test_component_list(client: Client) -> None:
assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_incident_list(client: Client) -> None:
"""This test ensures that the incident list is accessible."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_incidents/test_models/test_incident_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from firefighter.incidents.models import Incident


@pytest.mark.django_db()
@pytest.mark.django_db
class TestIncident(django.TestCase):
"""This is a property-based test that ensures model correctness."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from firefighter.incidents.models.user import User


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incident_detail_view(
client: Client, main_heading: str, incident_saved: Incident, admin_user: User
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_incidents/test_views/test_index_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from firefighter.incidents.models.user import User


@pytest.mark.django_db()
@pytest.mark.django_db
def test_main_page(client: Client, main_heading: str, admin_user: User) -> None:
"""This test ensures that main page works."""
client.force_login(admin_user)
Expand All @@ -17,7 +17,7 @@ def test_main_page(client: Client, main_heading: str, admin_user: User) -> None:
assert main_heading in str(response.content)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_hello_page(client: Client, main_heading: str, admin_user: User) -> None:
"""This test ensures that dashboard page works."""
client.force_login(admin_user)
Expand Down
Loading

0 comments on commit c943a30

Please sign in to comment.