Skip to content
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
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
language: system
entry: make -C api generate-docs
pass_filenames: false
types: [python,toml]
types: [python, toml]
- id: python-typecheck
name: python-typecheck
language: system
Expand All @@ -43,6 +43,11 @@ repos:
types: [python]
stages: [pre-push]

- repo: https://github.com/Flagsmith/flagsmith-common
rev: v3.4.0
hooks:
- id: flagsmith-lint-tests

- repo: https://github.com/python-poetry/poetry
rev: 2.3.2
hooks:
Expand Down
22 changes: 11 additions & 11 deletions api/tests/integration/api_keys/test_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from organisations.models import Organisation


def test_create_master_api_key_returns_key_in_response(admin_client, organisation): # type: ignore[no-untyped-def]
def test_create_master_api_key_returns_key_in_response(admin_client, organisation): # type: ignore[no-untyped-def] # noqa: FT003
# Given
url = reverse(
"api-v1:organisations:organisation-master-api-keys-list",
Expand All @@ -22,7 +22,7 @@ def test_create_master_api_key_returns_key_in_response(admin_client, organisatio
assert response.json()["is_admin"] is True


def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ignore[no-untyped-def]
def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ignore[no-untyped-def] # noqa: FT003
admin_client, organisation, settings
):
# Given
Expand All @@ -44,7 +44,7 @@ def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ig
]


def test_delete_master_api_key(admin_client, organisation, admin_master_api_key_prefix): # type: ignore[no-untyped-def] # noqa: E501
def test_delete_master_api_key(admin_client, organisation, admin_master_api_key_prefix): # type: ignore[no-untyped-def] # noqa: E501,FT003
# Given
url = reverse(
"api-v1:organisations:organisation-master-api-keys-detail",
Expand All @@ -58,7 +58,7 @@ def test_delete_master_api_key(admin_client, organisation, admin_master_api_key_
assert response.status_code == status.HTTP_204_NO_CONTENT


def test_list_master_api_keys(
def test_list_master_api_keys( # noqa: FT003
admin_client: APIClient,
organisation: int,
admin_master_api_key_prefix: str,
Expand All @@ -79,7 +79,7 @@ def test_list_master_api_keys(
assert response.json()["results"][0]["has_expired"] is False


def test_list_master_api_keys__when_expired(
def test_list_master_api_keys__when_expired( # noqa: FT003
admin_client: APIClient,
organisation: Organisation,
expired_api_key_prefix: str,
Expand All @@ -100,7 +100,7 @@ def test_list_master_api_keys__when_expired(
assert response.json()["results"][0]["has_expired"] is True


def test_retrieve_master_api_key( # type: ignore[no-untyped-def]
def test_retrieve_master_api_key( # type: ignore[no-untyped-def] # noqa: FT003
admin_client, organisation, admin_master_api_key_prefix
):
# Given
Expand All @@ -117,7 +117,7 @@ def test_retrieve_master_api_key( # type: ignore[no-untyped-def]
assert response.json()["prefix"] == admin_master_api_key_prefix


def test_update_master_api_key( # type: ignore[no-untyped-def]
def test_update_master_api_key( # type: ignore[no-untyped-def] # noqa: FT003
admin_client, organisation, admin_master_api_key_prefix, settings
):
# Given
Expand Down Expand Up @@ -147,7 +147,7 @@ def test_update_master_api_key( # type: ignore[no-untyped-def]
assert response.json()["is_admin"] is False


def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( # type: ignore[no-untyped-def]
def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( # type: ignore[no-untyped-def] # noqa: FT003
admin_client, organisation, admin_master_api_key_prefix, settings
):
# Given
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( #
]


def test_api_returns_403_if_user_is_not_the_org_admin(non_admin_client, organisation): # type: ignore[no-untyped-def]
def test_api_returns_403_if_user_is_not_the_org_admin(non_admin_client, organisation): # type: ignore[no-untyped-def] # noqa: FT003
# Given
url = reverse(
"api-v1:organisations:organisation-master-api-keys-list",
Expand All @@ -188,7 +188,7 @@ def test_api_returns_403_if_user_is_not_the_org_admin(non_admin_client, organisa
assert response.status_code == status.HTTP_403_FORBIDDEN


def test_create_master_api_key_ignores_organisation_in_body(admin_client, organisation): # type: ignore[no-untyped-def] # noqa: E501
def test_create_master_api_key_ignores_organisation_in_body(admin_client, organisation): # type: ignore[no-untyped-def] # noqa: E501,FT003
# Given
list_create_url = reverse(
"api-v1:organisations:organisation-master-api-keys-list",
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_create_master_api_key_ignores_organisation_in_body(admin_client, organi
assert key.startswith(list_response_json["results"][0]["prefix"])


def test_deleted_api_key_is_not_returned_in_list_and_cannot_be_used(
def test_deleted_api_key_is_not_returned_in_list_and_cannot_be_used( # noqa: FT003
admin_client: APIClient,
organisation: int,
admin_master_api_key_client: APIClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from rest_framework.test import APIClient


def test_influx_data_endpoint_is_throttled(
def test_influx_data_endpoint_is_throttled( # noqa: FT003
admin_client: APIClient,
organisation: int,
mocker: MockerFixture,
Expand Down
18 changes: 9 additions & 9 deletions api/tests/integration/audit/test_audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _subscription_metadata(mocker: MockerFixture) -> None:
)


def test_get_audit_logs_makes_expected_queries( # type: ignore[no-untyped-def]
def test_get_audit_logs_makes_expected_queries( # type: ignore[no-untyped-def] # noqa: FT003,FT004
admin_client,
project,
environment,
Expand All @@ -46,7 +46,7 @@ def test_get_audit_logs_makes_expected_queries( # type: ignore[no-untyped-def]
assert res.json()["count"] == 3


def test_retrieve_audit_log_for_environment_change(
def test_retrieve_audit_log_for_environment_change( # noqa: FT003,FT004
admin_client: APIClient,
project: int,
environment_api_key: str,
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_retrieve_audit_log_for_environment_change(
assert retrieve_response_json["change_details"][0]["old"] == environment_name


def test_retrieve_audit_log_for_feature_state_enabled_change(
def test_retrieve_audit_log_for_feature_state_enabled_change( # noqa: FT003
admin_client: APIClient,
environment_api_key: str,
environment: int,
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_retrieve_audit_log_for_feature_state_enabled_change(
assert retrieve_response_json["change_details"][0]["old"] is False


def test_creates_audit_log_for_feature_state_update(
def test_creates_audit_log_for_feature_state_update( # noqa: FT003
admin_client: APIClient,
admin_user: FFAdminUser,
environment_api_key: str,
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_creates_audit_log_for_feature_state_update(
("Asia/Tokyo", "Y年n月j日 H:i (T)", "2199年4月15日 21:30 (JST)"),
],
)
def test_creates_audit_log_for_scheduled_feature_state_update(
def test_creates_audit_log_for_scheduled_feature_state_update( # noqa: FT003
admin_client: APIClient,
admin_user: FFAdminUser,
django_datetime_format: str,
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_creates_audit_log_for_scheduled_feature_state_update(
)


def test_retrieve_audit_log_for_feature_state_value_change(
def test_retrieve_audit_log_for_feature_state_value_change( # noqa: FT003
admin_client: APIClient,
environment_api_key: str,
environment: int,
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_retrieve_audit_log_for_feature_state_value_change(
assert retrieve_response_json["change_details"][0]["old"] == default_feature_value


def test_retrieve_audit_log_does_not_include_change_details_for_non_update(
def test_retrieve_audit_log_does_not_include_change_details_for_non_update( # noqa: FT003
admin_client: APIClient, project: int, environment: str
) -> None:
# Given
Expand All @@ -288,7 +288,7 @@ def test_retrieve_audit_log_does_not_include_change_details_for_non_update(
assert retrieve_response.json()["change_details"] == []


def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_deleted_for_enabled_state(
def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_deleted_for_enabled_state( # noqa: FT003,FT004
admin_client: APIClient,
project: int,
feature: int,
Expand Down Expand Up @@ -380,7 +380,7 @@ def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_d
assert delete_override_audit_log_details["change_details"] == []


def test_retrieve_audit_log_includes_changes_when_segment_override_created_for_feature_value(
def test_retrieve_audit_log_includes_changes_when_segment_override_created_for_feature_value( # noqa: FT003,FT004
admin_client: APIClient,
project: int,
feature: int,
Expand Down
4 changes: 2 additions & 2 deletions api/tests/integration/core/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_bootstrap__empty_instance__creates_expected(
)


def test_bootstrap__empty_instance__cli_overrides__creates_expected(
def test_bootstrap__empty_instance__cli_overrides__creates_expected( # noqa: FT003
settings: SettingsWrapper,
capsys: pytest.CaptureFixture, # type: ignore[type-arg]
) -> None:
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_bootstrap__used_instance__skip_expected(
[*Project.objects.all()] == expected_projects


def test_bootstrap__allow_admin_initiation_via_cli__false_by_default__skip_expected(
def test_bootstrap__allow_admin_initiation_via_cli__false_by_default__skip_expected( # noqa: FT003,FT004
settings: SettingsWrapper,
) -> None:
# When
Expand Down
14 changes: 7 additions & 7 deletions api/tests/integration/core/test_user_rate_throttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"client",
[(lazy_fixture("admin_master_api_key_client")), (lazy_fixture("admin_client"))],
)
def test_user_throttle_can_throttle_admin_endpoints(
def test_user_throttle_can_throttle_admin_endpoints( # noqa: FT003,FT004
client: APIClient, project: int, mocker: MockerFixture, reset_cache: None
) -> None:
# Given
Expand All @@ -29,7 +29,7 @@ def test_user_throttle_can_throttle_admin_endpoints(
assert response.status_code == status.HTTP_429_TOO_MANY_REQUESTS


def test_get_flags_is_not_throttled_by_user_throttle(
def test_get_flags_is_not_throttled_by_user_throttle( # noqa: FT003
sdk_client: APIClient,
environment: int,
environment_api_key: str,
Expand All @@ -48,7 +48,7 @@ def test_get_flags_is_not_throttled_by_user_throttle(
assert response.status_code == status.HTTP_200_OK


def test_get_environment_document_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
def test_get_environment_document_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
server_side_sdk_client: APIClient,
environment: int,
environment_api_key: str,
Expand All @@ -67,7 +67,7 @@ def test_get_environment_document_is_not_throttled_by_user_throttle( # type: ig
assert response.status_code == status.HTTP_200_OK


def test_get_identities_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
def test_get_identities_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
environment: int,
sdk_client: APIClient,
mocker: MockerFixture,
Expand All @@ -88,7 +88,7 @@ def test_get_identities_is_not_throttled_by_user_throttle( # type: ignore[no-un
assert response.status_code == status.HTTP_200_OK


def test_set_trait_for_an_identity_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
def test_set_trait_for_an_identity_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
environment: int,
server_side_sdk_client: APIClient,
identity: int,
Expand All @@ -114,7 +114,7 @@ def test_set_trait_for_an_identity_is_not_throttled_by_user_throttle( # type: i
assert res.status_code == status.HTTP_200_OK


def test_sdk_analytics_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
def test_sdk_analytics_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
mocker: MockerFixture, environment: int, sdk_client: APIClient
):
# Given
Expand All @@ -128,7 +128,7 @@ def test_sdk_analytics_is_not_throttled_by_user_throttle( # type: ignore[no-unt
assert response.status_code == status.HTTP_200_OK


def test_self_hosted_telemetry_view_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
def test_self_hosted_telemetry_view_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
mocker: MockerFixture,
):
# Given
Expand Down
Loading
Loading