fix pre-commit #18
1
.gitignore
vendored
1
.gitignore
vendored
@@ -45,3 +45,4 @@ data/
|
|||||||
.env.prod
|
.env.prod
|
||||||
tmp/
|
tmp/
|
||||||
_tmp/
|
_tmp/
|
||||||
|
input/fns/processed/*.xlsx
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ class ExchangePeriodicTaskSerializer(serializers.ModelSerializer):
|
|||||||
return int(value) if str(value).isdigit() else None
|
return int(value) if str(value).isdigit() else None
|
||||||
|
|
||||||
def get_crontab_minute(self, obj: PeriodicTask) -> int | None:
|
def get_crontab_minute(self, obj: PeriodicTask) -> int | None:
|
||||||
return self._coerce_crontab_number(obj.crontab.minute) if obj.crontab_id else None
|
return (
|
||||||
|
self._coerce_crontab_number(obj.crontab.minute) if obj.crontab_id else None
|
||||||
|
)
|
||||||
|
|
||||||
def get_crontab_hour(self, obj: PeriodicTask) -> int | None:
|
def get_crontab_hour(self, obj: PeriodicTask) -> int | None:
|
||||||
return self._coerce_crontab_number(obj.crontab.hour) if obj.crontab_id else None
|
return self._coerce_crontab_number(obj.crontab.hour) if obj.crontab_id else None
|
||||||
@@ -216,11 +218,7 @@ class ExchangePeriodicTaskUpsertSerializer(serializers.Serializer):
|
|||||||
schedule_type = str(attrs["schedule_type"]).strip().lower()
|
schedule_type = str(attrs["schedule_type"]).strip().lower()
|
||||||
if schedule_type not in {"interval", "daily"}:
|
if schedule_type not in {"interval", "daily"}:
|
||||||
raise serializers.ValidationError(
|
raise serializers.ValidationError(
|
||||||
{
|
{"schedule_type": ("Допустимые значения: interval или daily.")}
|
||||||
"schedule_type": (
|
|
||||||
"Допустимые значения: interval или daily."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return schedule_type
|
return schedule_type
|
||||||
|
|
||||||
|
|||||||
@@ -901,7 +901,10 @@ class SourceCardRefreshView(APIView):
|
|||||||
)
|
)
|
||||||
output = SourceCardRefreshResponseSerializer(payload).data
|
output = SourceCardRefreshResponseSerializer(payload).data
|
||||||
tasks = output.get("tasks", [])
|
tasks = output.get("tasks", [])
|
||||||
response_payload = {"task_id": tasks[0]["task_id"] if tasks else None, "status": "accepted"}
|
response_payload = {
|
||||||
|
"task_id": tasks[0]["task_id"] if tasks else None,
|
||||||
|
"status": "accepted",
|
||||||
|
}
|
||||||
return Response(
|
return Response(
|
||||||
response_payload,
|
response_payload,
|
||||||
status=status.HTTP_202_ACCEPTED,
|
status=status.HTTP_202_ACCEPTED,
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ ADMIN_USER_LIST_RESPONSE = openapi.Response(
|
|||||||
type=openapi.TYPE_OBJECT,
|
type=openapi.TYPE_OBJECT,
|
||||||
properties={
|
properties={
|
||||||
"count": openapi.Schema(type=openapi.TYPE_INTEGER),
|
"count": openapi.Schema(type=openapi.TYPE_INTEGER),
|
||||||
"next": openapi.Schema(type=openapi.TYPE_STRING, format="uri", nullable=True),
|
"next": openapi.Schema(
|
||||||
|
type=openapi.TYPE_STRING, format="uri", nullable=True
|
||||||
|
),
|
||||||
"previous": openapi.Schema(
|
"previous": openapi.Schema(
|
||||||
type=openapi.TYPE_STRING, format="uri", nullable=True
|
type=openapi.TYPE_STRING, format="uri", nullable=True
|
||||||
),
|
),
|
||||||
@@ -372,9 +374,7 @@ class AdminUserListCreateView(APIView):
|
|||||||
ordering=request.query_params.get("ordering", ""),
|
ordering=request.query_params.get("ordering", ""),
|
||||||
)
|
)
|
||||||
paginated = _paginate_user_queryset(request, queryset)
|
paginated = _paginate_user_queryset(request, queryset)
|
||||||
serializer = FrontendUserWithProfileSerializer(
|
serializer = FrontendUserWithProfileSerializer(paginated["results"], many=True)
|
||||||
paginated["results"], many=True
|
|
||||||
)
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"count": paginated["count"],
|
"count": paginated["count"],
|
||||||
|
|||||||
@@ -36,14 +36,18 @@ class ExchangeCopyRequestSerializerTest(SimpleTestCase):
|
|||||||
|
|
||||||
class ExchangePeriodicTaskUpsertSerializerTest(SimpleTestCase):
|
class ExchangePeriodicTaskUpsertSerializerTest(SimpleTestCase):
|
||||||
def test_interval_schedule_requires_fields(self):
|
def test_interval_schedule_requires_fields(self):
|
||||||
serializer = ExchangePeriodicTaskUpsertSerializer(data={"schedule_type": "interval"})
|
serializer = ExchangePeriodicTaskUpsertSerializer(
|
||||||
|
data={"schedule_type": "interval"}
|
||||||
|
)
|
||||||
|
|
||||||
self.assertFalse(serializer.is_valid())
|
self.assertFalse(serializer.is_valid())
|
||||||
self.assertIn("interval_every", serializer.errors)
|
self.assertIn("interval_every", serializer.errors)
|
||||||
self.assertIn("interval_period", serializer.errors)
|
self.assertIn("interval_period", serializer.errors)
|
||||||
|
|
||||||
def test_daily_schedule_requires_fields(self):
|
def test_daily_schedule_requires_fields(self):
|
||||||
serializer = ExchangePeriodicTaskUpsertSerializer(data={"schedule_type": "daily"})
|
serializer = ExchangePeriodicTaskUpsertSerializer(
|
||||||
|
data={"schedule_type": "daily"}
|
||||||
|
)
|
||||||
|
|
||||||
self.assertFalse(serializer.is_valid())
|
self.assertFalse(serializer.is_valid())
|
||||||
self.assertIn("crontab_minute", serializer.errors)
|
self.assertIn("crontab_minute", serializer.errors)
|
||||||
|
|||||||
Reference in New Issue
Block a user