Skip to content

Commit 41eb36b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 75004e5 commit 41eb36b

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

api/environments/tasks.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from django.db import IntegrityError, OperationalError, transaction
2-
from django.db.transaction import TransactionManagementError
3-
from task_processor.exceptions import TaskBackoffError
4-
from django.db import transaction
5-
from django.core.exceptions import ObjectDoesNotExist
62
from django.db.models import Prefetch, Q
3+
from django.db.transaction import TransactionManagementError
74
from django.utils import timezone
85
from task_processor.decorators import (
96
register_task_handler,
107
)
8+
from task_processor.exceptions import TaskBackoffError
119
from task_processor.models import TaskPriority
1210

1311
from audit.models import AuditLog
@@ -75,6 +73,7 @@ def delete_environment(environment_id: int) -> None:
7573
# Someone else is locking these rows, back off and retry
7674
raise TaskBackoffError()
7775

76+
7877
@register_task_handler()
7978
def clone_environment_feature_states(
8079
source_environment_id: int, clone_environment_id: int

api/features/tasks.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from django.db import IntegrityError, OperationalError, transaction
2-
from django.db.transaction import TransactionManagementError
3-
from task_processor.exceptions import TaskBackoffError
4-
51
import logging
62
from typing import Any
73

4+
from django.db import IntegrityError, OperationalError, transaction
5+
from django.db.transaction import TransactionManagementError
86
from task_processor.decorators import (
97
register_task_handler,
108
)
9+
from task_processor.exceptions import TaskBackoffError
1110

1211
from environments.models import Webhook
1312
from features.models import Feature, FeatureState
@@ -166,9 +165,9 @@ def delete_feature(feature_id: int) -> None:
166165
try:
167166
with transaction.atomic():
168167
Feature.objects.get(pk=feature_id).delete()
169-
168+
170169
except Feature.DoesNotExist:
171170
pass
172-
171+
173172
except (OperationalError, IntegrityError, TransactionManagementError):
174173
raise TaskBackoffError()

api/tests/unit/environments/test_unit_environments_tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from pytest_mock import MockerFixture
21
from django.db import OperationalError
2+
from pytest_mock import MockerFixture
33
from task_processor.exceptions import TaskBackoffError
4-
from environments.models import Environment
5-
from environments.tasks import delete_environment
4+
65
from audit.models import AuditLog
76
from environments.models import Environment
87
from environments.tasks import (
8+
delete_environment,
99
delete_environment_from_dynamo,
1010
process_environment_update,
1111
rebuild_environment_document,
@@ -116,6 +116,8 @@ def test_delete_environment__calls_internal_methods_correctly(
116116
mocked_identity_wrapper.delete_all_identities.assert_called_once_with(
117117
environment_api_key
118118
)
119+
120+
119121
@pytest.mark.django_db
120122
def test_delete_environment__environment_does_not_exist__succeeds_silently(
121123
mocker: MockerFixture,

api/tests/unit/features/test_unit_features_tasks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import pytest
2+
from django.db import OperationalError
23
from pytest_lazyfixture import lazy_fixture # type: ignore[import-untyped]
34
from pytest_mock import MockerFixture
4-
from unittest import mock
5-
from django.db import OperationalError
65
from task_processor.exceptions import TaskBackoffError
7-
from features.tasks import delete_feature
6+
87
from api_keys.models import MasterAPIKey
98
from environments.models import Environment
109
from features.models import Feature, FeatureState
11-
from features.tasks import trigger_feature_state_change_webhooks
10+
from features.tasks import delete_feature, trigger_feature_state_change_webhooks
1211
from organisations.models import Organisation
1312
from projects.models import Project
1413
from users.models import FFAdminUser
@@ -166,6 +165,7 @@ def test_trigger_feature_state_change_webhooks_for_deleted_flag_uses_fs_instance
166165
assert data["previous_state"]["feature"]["id"] == feature_state.feature.id
167166
assert event_type == WebhookEventType.FLAG_DELETED.value
168167

168+
169169
@pytest.mark.django_db
170170
def test_delete_feature__feature_does_not_exist__succeeds_silently(
171171
mocker: MockerFixture,

0 commit comments

Comments
 (0)