From 424a1060c7404264449adb49b1ba293ab7fdb05b Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:36:40 +0200 Subject: [PATCH] ruff --- dojo/api_v2/views.py | 2 +- dojo/notifications/views.py | 8 ++++---- unittests/test_notifications.py | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dojo/api_v2/views.py b/dojo/api_v2/views.py index e1651812ed..a468456267 100644 --- a/dojo/api_v2/views.py +++ b/dojo/api_v2/views.py @@ -3314,7 +3314,7 @@ class AnnouncementViewSet( class NotificationWebhooksViewSet( - PrefetchDojoModelViewSet + PrefetchDojoModelViewSet, ): serializer_class = serializers.NotificationWebhooksSerializer queryset = Notification_Webhooks.objects.all() diff --git a/dojo/notifications/views.py b/dojo/notifications/views.py index d269a20039..4ad520737e 100644 --- a/dojo/notifications/views.py +++ b/dojo/notifications/views.py @@ -138,11 +138,11 @@ class NotificationWebhooksView(View): def check_webhooks_enabled(self): if not get_system_setting('enable_webhooks_notifications'): - raise Http404() + raise Http404 def check_user_permissions(self, request: HttpRequest): if not request.user.is_superuser: - raise PermissionDenied() + raise PermissionDenied # TODO finished access for other users # if not user_has_configuration_permission(request.user, self.permission): # raise PermissionDenied() @@ -288,7 +288,7 @@ def get_initial_context(self, request: HttpRequest, nwh: Notification_Webhooks): 'name': 'Edit Notification Webhook', 'user': request.user, 'form': self.get_form(request, instance=nwh), - 'nwh': nwh + 'nwh': nwh, } def process_form(self, request: HttpRequest, nwh: Notification_Webhooks, context: dict): @@ -383,7 +383,7 @@ def get_form( def get_initial_context(self, request: HttpRequest, nwh: Notification_Webhooks): return { 'form': self.get_form(request, instance=nwh), - 'nwh': nwh + 'nwh': nwh, } def process_form(self, request: HttpRequest, nwh: Notification_Webhooks, context: dict): diff --git a/unittests/test_notifications.py b/unittests/test_notifications.py index 491c62cc84..7e85dc1d1c 100644 --- a/unittests/test_notifications.py +++ b/unittests/test_notifications.py @@ -501,7 +501,7 @@ def test_headers(self, mock): 'X-DefectDojo-Event': 'product_type_added', 'X-DefectDojo-Instance': 'http://localhost:8080', 'Accept': 'application/json', - 'Auth': 'Token xxx' + 'Auth': 'Token xxx', }) @patch('requests.request') @@ -619,16 +619,16 @@ def test_events_messages(self, mock): notifications_helper.notify_scan_added(test, updated_count=4, new_findings=[ - Finding.objects.create(test=test, title='New Finding', severity='Critical') + Finding.objects.create(test=test, title='New Finding', severity='Critical'), ], findings_mitigated=[ - Finding.objects.create(test=test, title='Mitigated Finding', severity='Medium') + Finding.objects.create(test=test, title='Mitigated Finding', severity='Medium'), ], findings_reactivated=[ - Finding.objects.create(test=test, title='Reactivated Finding', severity='Low') + Finding.objects.create(test=test, title='Reactivated Finding', severity='Low'), ], findings_untouched=[ - Finding.objects.create(test=test, title='Untouched Finding', severity='Info') + Finding.objects.create(test=test, title='Untouched Finding', severity='Info'), ], ) self.assertEqual(mock.call_args.kwargs['headers']['X-DefectDojo-Event'], 'scan_added') @@ -638,24 +638,24 @@ def test_events_messages(self, mock): 'id': 232, 'title': 'New Finding', 'severity': 'Critical', - 'url': 'http://localhost:8080/finding/232' + 'url': 'http://localhost:8080/finding/232', }], 'mitigated': [{ 'id': 233, 'title': 'Mitigated Finding', 'severity': 'Medium', - 'url': 'http://localhost:8080/finding/233' + 'url': 'http://localhost:8080/finding/233', }], 'reactivated': [{ 'id': 234, 'title': 'Reactivated Finding', 'severity': 'Low', - 'url': 'http://localhost:8080/finding/234' + 'url': 'http://localhost:8080/finding/234', }], 'untouched': [{ 'id': 235, 'title': 'Untouched Finding', 'severity': 'Info', - 'url': 'http://localhost:8080/finding/235' + 'url': 'http://localhost:8080/finding/235', }], })