Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #80

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: fix-byte-order-marker
# Versions must be kept in sync with lockfile
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.10'
rev: 'v0.6.5'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
3 changes: 1 addition & 2 deletions src/firefighter/slack/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ def save_model(
group_slack_id=obj.usergroup_id
)
elif obj.handle:
if obj.handle.startswith("@"):
obj.handle = obj.handle[1:]
obj.handle = obj.handle.removeprefix("@")
obj.handle.strip()
fetch_obj = UserGroup.objects.fetch_usergroup(group_handle=obj.handle)
if fetch_obj:
Expand Down
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
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>'


@pytest.fixture(scope="session")
def django_db_setup( # noqa: PT004
def django_db_setup(

Check failure on line 50 in tests/conftest.py

View workflow job for this annotation

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

Ruff (PT004)

tests/conftest.py:50:5: PT004 Fixture `django_db_setup` does not return anything, add leading underscore

Check failure on line 50 in tests/conftest.py

View workflow job for this annotation

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

Ruff (PT004)

tests/conftest.py:50:5: PT004 Fixture `django_db_setup` does not return anything, add leading underscore
django_db_setup: Any, django_db_blocker: DjangoDbBlocker
) -> None:
# XXX Allow override of fixtures path
Expand Down Expand Up @@ -76,13 +76,13 @@
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 @@
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 @@
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 @@
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 @@
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
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
8 changes: 4 additions & 4 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 All @@ -60,7 +60,7 @@ def test_grouped_model_choice_field_invalid() -> None:


@pytest.fixture(scope="module")
def test_grouped_model_choice_field_grouping( # noqa: PT004
def test_grouped_model_choice_field_grouping(
components: list[Component],
):
form = GroupedModelChoiceFieldForm()
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
Loading
Loading