Skip to content

Commit d3c94e4

Browse files
committed
chore: Add flagsmith-lint-tests hook and suppress existing violations
Add the flagsmith-lint-tests pre-commit hook from flagsmith-common (fv3.4.0) and add # noqa comments to all existing test violations.
1 parent 6fea4c6 commit d3c94e4

File tree

253 files changed

+2063
-2068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+2063
-2068
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ repos:
3333
language: system
3434
entry: make -C api generate-docs
3535
pass_filenames: false
36-
types: [python,toml]
36+
types: [python, toml]
3737
- id: python-typecheck
3838
name: python-typecheck
3939
language: system
@@ -44,7 +44,7 @@ repos:
4444
stages: [pre-push]
4545

4646
- repo: https://github.com/Flagsmith/flagsmith-common
47-
rev: feat/lint-tests-ft-rules
47+
rev: v3.4.0
4848
hooks:
4949
- id: flagsmith-lint-tests
5050

api/tests/integration/api_keys/test_viewset.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from organisations.models import Organisation
66

77

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

2424

25-
def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ignore[no-untyped-def]
25+
def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ignore[no-untyped-def] # noqa: FT003
2626
admin_client, organisation, settings
2727
):
2828
# Given
@@ -44,7 +44,7 @@ def test_creating_non_admin_master_api_key_without_rbac_returns_400( # type: ig
4444
]
4545

4646

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

6060

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

8181

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

102102

103-
def test_retrieve_master_api_key( # type: ignore[no-untyped-def]
103+
def test_retrieve_master_api_key( # type: ignore[no-untyped-def] # noqa: FT003
104104
admin_client, organisation, admin_master_api_key_prefix
105105
):
106106
# Given
@@ -117,7 +117,7 @@ def test_retrieve_master_api_key( # type: ignore[no-untyped-def]
117117
assert response.json()["prefix"] == admin_master_api_key_prefix
118118

119119

120-
def test_update_master_api_key( # type: ignore[no-untyped-def]
120+
def test_update_master_api_key( # type: ignore[no-untyped-def] # noqa: FT003
121121
admin_client, organisation, admin_master_api_key_prefix, settings
122122
):
123123
# Given
@@ -147,7 +147,7 @@ def test_update_master_api_key( # type: ignore[no-untyped-def]
147147
assert response.json()["is_admin"] is False
148148

149149

150-
def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( # type: ignore[no-untyped-def]
150+
def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( # type: ignore[no-untyped-def] # noqa: FT003
151151
admin_client, organisation, admin_master_api_key_prefix, settings
152152
):
153153
# Given
@@ -175,7 +175,7 @@ def test_update_master_api_key_is_admin_returns_400_if_rbac_is_not_installed( #
175175
]
176176

177177

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

190190

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

218218

219-
def test_deleted_api_key_is_not_returned_in_list_and_cannot_be_used(
219+
def test_deleted_api_key_is_not_returned_in_list_and_cannot_be_used( # noqa: FT003
220220
admin_client: APIClient,
221221
organisation: int,
222222
admin_master_api_key_client: APIClient,

api/tests/integration/app_analytics/test_influx_query_throttle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from rest_framework.test import APIClient
55

66

7-
def test_influx_data_endpoint_is_throttled(
7+
def test_influx_data_endpoint_is_throttled( # noqa: FT003
88
admin_client: APIClient,
99
organisation: int,
1010
mocker: MockerFixture,

api/tests/integration/audit/test_audit_logs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _subscription_metadata(mocker: MockerFixture) -> None:
2929
)
3030

3131

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

4848

49-
def test_retrieve_audit_log_for_environment_change(
49+
def test_retrieve_audit_log_for_environment_change( # noqa: FT003,FT004
5050
admin_client: APIClient,
5151
project: int,
5252
environment_api_key: str,
@@ -88,7 +88,7 @@ def test_retrieve_audit_log_for_environment_change(
8888
assert retrieve_response_json["change_details"][0]["old"] == environment_name
8989

9090

91-
def test_retrieve_audit_log_for_feature_state_enabled_change(
91+
def test_retrieve_audit_log_for_feature_state_enabled_change( # noqa: FT003
9292
admin_client: APIClient,
9393
environment_api_key: str,
9494
environment: int,
@@ -132,7 +132,7 @@ def test_retrieve_audit_log_for_feature_state_enabled_change(
132132
assert retrieve_response_json["change_details"][0]["old"] is False
133133

134134

135-
def test_creates_audit_log_for_feature_state_update(
135+
def test_creates_audit_log_for_feature_state_update( # noqa: FT003
136136
admin_client: APIClient,
137137
admin_user: FFAdminUser,
138138
environment_api_key: str,
@@ -170,7 +170,7 @@ def test_creates_audit_log_for_feature_state_update(
170170
("Asia/Tokyo", "Y年n月j日 H:i (T)", "2199年4月15日 21:30 (JST)"),
171171
],
172172
)
173-
def test_creates_audit_log_for_scheduled_feature_state_update(
173+
def test_creates_audit_log_for_scheduled_feature_state_update( # noqa: FT003
174174
admin_client: APIClient,
175175
admin_user: FFAdminUser,
176176
django_datetime_format: str,
@@ -216,7 +216,7 @@ def test_creates_audit_log_for_scheduled_feature_state_update(
216216
)
217217

218218

219-
def test_retrieve_audit_log_for_feature_state_value_change(
219+
def test_retrieve_audit_log_for_feature_state_value_change( # noqa: FT003
220220
admin_client: APIClient,
221221
environment_api_key: str,
222222
environment: int,
@@ -262,7 +262,7 @@ def test_retrieve_audit_log_for_feature_state_value_change(
262262
assert retrieve_response_json["change_details"][0]["old"] == default_feature_value
263263

264264

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

290290

291-
def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_deleted_for_enabled_state(
291+
def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_deleted_for_enabled_state( # noqa: FT003,FT004
292292
admin_client: APIClient,
293293
project: int,
294294
feature: int,
@@ -380,7 +380,7 @@ def test_retrieve_audit_log_includes_changes_when_segment_override_created_and_d
380380
assert delete_override_audit_log_details["change_details"] == []
381381

382382

383-
def test_retrieve_audit_log_includes_changes_when_segment_override_created_for_feature_value(
383+
def test_retrieve_audit_log_includes_changes_when_segment_override_created_for_feature_value( # noqa: FT003,FT004
384384
admin_client: APIClient,
385385
project: int,
386386
feature: int,

api/tests/integration/core/test_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_bootstrap__empty_instance__creates_expected(
9797
)
9898

9999

100-
def test_bootstrap__empty_instance__cli_overrides__creates_expected(
100+
def test_bootstrap__empty_instance__cli_overrides__creates_expected( # noqa: FT003
101101
settings: SettingsWrapper,
102102
capsys: pytest.CaptureFixture, # type: ignore[type-arg]
103103
) -> None:
@@ -156,7 +156,7 @@ def test_bootstrap__used_instance__skip_expected(
156156
[*Project.objects.all()] == expected_projects
157157

158158

159-
def test_bootstrap__allow_admin_initiation_via_cli__false_by_default__skip_expected(
159+
def test_bootstrap__allow_admin_initiation_via_cli__false_by_default__skip_expected( # noqa: FT003,FT004
160160
settings: SettingsWrapper,
161161
) -> None:
162162
# When

api/tests/integration/core/test_user_rate_throttle.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"client",
1313
[(lazy_fixture("admin_master_api_key_client")), (lazy_fixture("admin_client"))],
1414
)
15-
def test_user_throttle_can_throttle_admin_endpoints(
15+
def test_user_throttle_can_throttle_admin_endpoints( # noqa: FT003,FT004
1616
client: APIClient, project: int, mocker: MockerFixture, reset_cache: None
1717
) -> None:
1818
# Given
@@ -29,7 +29,7 @@ def test_user_throttle_can_throttle_admin_endpoints(
2929
assert response.status_code == status.HTTP_429_TOO_MANY_REQUESTS
3030

3131

32-
def test_get_flags_is_not_throttled_by_user_throttle(
32+
def test_get_flags_is_not_throttled_by_user_throttle( # noqa: FT003
3333
sdk_client: APIClient,
3434
environment: int,
3535
environment_api_key: str,
@@ -48,7 +48,7 @@ def test_get_flags_is_not_throttled_by_user_throttle(
4848
assert response.status_code == status.HTTP_200_OK
4949

5050

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

6969

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

9090

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

116116

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

130130

131-
def test_self_hosted_telemetry_view_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def]
131+
def test_self_hosted_telemetry_view_is_not_throttled_by_user_throttle( # type: ignore[no-untyped-def] # noqa: FT003
132132
mocker: MockerFixture,
133133
):
134134
# Given

0 commit comments

Comments
 (0)