From 034ebaf56669fa949dcd0aad9aca7f0895968645 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 28 Nov 2024 15:39:19 +0100 Subject: [PATCH] Remove f-string without any placeholders --- src/argus/incident/V1/serializers.py | 2 +- src/argus/incident/serializers.py | 2 +- tests/dev/test_create_fake_incident.py | 4 +- tests/dev/test_utils.py | 2 +- tests/incident/test_views.py | 48 +++++++++---------- .../destinations/test_email.py | 4 +- .../destinations/test_sms.py | 4 +- tests/notificationprofile/test_views.py | 4 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/argus/incident/V1/serializers.py b/src/argus/incident/V1/serializers.py index bb5b6fd6a..b7dfbd1f3 100644 --- a/src/argus/incident/V1/serializers.py +++ b/src/argus/incident/V1/serializers.py @@ -113,7 +113,7 @@ class Meta: def update(self, instance, validated_data): now = self.__class__._later_than_func() if instance.expiration and instance.expiration < now: # expired are readonly - raise serializers.ValidationError(f"Cannot change expired Acknowledgement") + raise serializers.ValidationError("Cannot change expired Acknowledgement") expiration = validated_data.get("expiration") instance.expiration = expiration instance.save() diff --git a/src/argus/incident/serializers.py b/src/argus/incident/serializers.py index 8a9de07c3..8319db50d 100644 --- a/src/argus/incident/serializers.py +++ b/src/argus/incident/serializers.py @@ -342,7 +342,7 @@ class Meta: def update(self, instance, validated_data): now = self.__class__._later_than_func() if instance.expiration and instance.expiration < now: # expired are readonly - raise serializers.ValidationError(f"Cannot change expired Acknowledgement") + raise serializers.ValidationError("Cannot change expired Acknowledgement") expiration = validated_data.get("expiration") instance.expiration = expiration instance.save() diff --git a/tests/dev/test_create_fake_incident.py b/tests/dev/test_create_fake_incident.py index c83bfc469..f27185758 100644 --- a/tests/dev/test_create_fake_incident.py +++ b/tests/dev/test_create_fake_incident.py @@ -84,7 +84,7 @@ def test_create_fake_incident_will_create_single_fake_incident_with_set_level(se def test_create_fake_incident_will_raise_error_for_invalid_level(self): with self.assertRaises(CommandError): - self.call_command(f"--level=100") + self.call_command("--level=100") def test_create_fake_incident_will_create_single_fake_incident_with_set_tag(self): previous_incidents_pks = [incident.id for incident in Incident.objects.all()] @@ -105,7 +105,7 @@ def test_create_fake_incident_will_create_single_fake_incident_with_set_tag(self def test_create_fake_incident_will_create_single_fake_stateless_incident(self): previous_incidents_pks = [incident.id for incident in Incident.objects.all()] - out = self.call_command(f"--stateless") + out = self.call_command("--stateless") self.assertFalse(out) diff --git a/tests/dev/test_utils.py b/tests/dev/test_utils.py index c0982bd1a..ead60e929 100644 --- a/tests/dev/test_utils.py +++ b/tests/dev/test_utils.py @@ -52,7 +52,7 @@ def test_verify_description_does_not_raise_exception_for_correct_description(sel self.stresstester._verify_description(actual_data, expected_data) def test_get_auth_header_returns_correct_header_values(self): - self.assertEqual(self.stresstester._get_auth_header(), {"Authorization": f"Token token"}) + self.assertEqual(self.stresstester._get_auth_header(), {"Authorization": "Token token"}) def test_get_incidents_v1_url_returns_correct_url(self): self.assertEqual(self.stresstester._get_incidents_v1_url(), "http://localhost.com/api/v1/incidents/") diff --git a/tests/incident/test_views.py b/tests/incident/test_views.py index 77c1b24c6..928103a9f 100644 --- a/tests/incident/test_views.py +++ b/tests/incident/test_views.py @@ -392,7 +392,7 @@ class SourceSystemV1TestCase(IncidentAPITestCase): def test_can_get_all_source_types(self): source_type_names = set([type.name for type in SourceSystemType.objects.all()]) - response = self.client.get(path=f"/api/v1/incidents/source-types/") + response = self.client.get(path="/api/v1/incidents/source-types/") self.assertEqual(response.status_code, status.HTTP_200_OK) response_types = set([type["name"] for type in response.data]) @@ -407,14 +407,14 @@ def test_can_create_source_type(self): data = { "name": "test", } - response = self.client.post(path=f"/api/v1/incidents/source-types/", data=data, format="json") + response = self.client.post(path="/api/v1/incidents/source-types/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(SourceSystemType.objects.filter(name=data["name"]).exists()) def test_can_get_all_source_systems(self): source_pks = set([source.pk for source in SourceSystem.objects.all()]) - response = self.client.get(path=f"/api/v1/incidents/sources/") + response = self.client.get(path="/api/v1/incidents/sources/") self.assertEqual(response.status_code, status.HTTP_200_OK) response_source_pks = set([source["pk"] for source in response.data]) @@ -432,7 +432,7 @@ def test_can_create_source_system(self): "name": "newtest", "type": self.source.type.name, } - response = self.client.post(path=f"/api/v1/incidents/sources/", data=data, format="json") + response = self.client.post(path="/api/v1/incidents/sources/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(SourceSystem.objects.filter(name=data["name"]).exists()) @@ -881,7 +881,7 @@ def test_can_get_all_events(self): self.add_open_incident_with_start_event_and_tag() event_pks = list(Event.objects.all().values_list("pk", flat=True)) - response = self.client.get(path=f"/api/v2/incidents/events/") + response = self.client.get(path="/api/v2/incidents/events/") self.assertEqual(response.status_code, status.HTTP_200_OK) # Paging, so check "results" @@ -891,7 +891,7 @@ def test_can_get_all_events(self): def test_can_get_all_source_types(self): source_type_names = set([type.name for type in SourceSystemType.objects.all()]) - response = self.client.get(path=f"/api/v2/incidents/source-types/") + response = self.client.get(path="/api/v2/incidents/source-types/") self.assertEqual(response.status_code, status.HTTP_200_OK) response_types = set([type["name"] for type in response.data]) @@ -906,14 +906,14 @@ def test_can_create_source_type(self): data = { "name": "test", } - response = self.client.post(path=f"/api/v2/incidents/source-types/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/source-types/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(SourceSystemType.objects.filter(name=data["name"]).exists()) def test_can_get_all_source_systems(self): source_pks = set([source.pk for source in SourceSystem.objects.all()]) - response = self.client.get(path=f"/api/v2/incidents/sources/") + response = self.client.get(path="/api/v2/incidents/sources/") self.assertEqual(response.status_code, status.HTTP_200_OK) response_source_pks = set([source["pk"] for source in response.data]) @@ -931,7 +931,7 @@ def test_can_create_source_system(self): "name": "newtest", "type": self.source.type.name, } - response = self.client.post(path=f"/api/v2/incidents/sources/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/sources/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(SourceSystem.objects.filter(name=data["name"]).exists()) @@ -970,7 +970,7 @@ def test_can_bulk_create_acknowledgements_for_incidents_with_valid_ids(self): "ack": self.ack_data, } - response = self.client.post(path=f"/api/v2/incidents/acks/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/acks/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -997,7 +997,7 @@ def test_can_bulk_create_acknowledgements_without_description_and_expiration_for }, } - response = self.client.post(path=f"/api/v2/incidents/acks/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/acks/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1029,7 +1029,7 @@ def test_can_bulk_create_acknowledgements_with_empty_description_for_incidents_w }, } - response = self.client.post(path=f"/api/v2/incidents/acks/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/acks/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1057,7 +1057,7 @@ def test_cannot_bulk_create_acknowledgements_for_incidents_with_all_invalid_ids( "ack": self.ack_data, } - response = self.client.post(path=f"/api/v2/incidents/acks/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/acks/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1083,7 +1083,7 @@ def test_can_partially_bulk_create_acknowledgements_for_incidents_with_some_vali "ack": self.ack_data, } - response = self.client.post(path=f"/api/v2/incidents/acks/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/acks/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1125,7 +1125,7 @@ def test_can_bulk_create_events_for_incidents_with_valid_ids(self): "event": self.event_data, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1153,7 +1153,7 @@ def test_can_bulk_create_events_without_description_for_incidents_with_valid_ids }, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1184,7 +1184,7 @@ def test_can_bulk_create_events_with_description_empty_string_for_incidents_with }, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1215,7 +1215,7 @@ def test_bulk_close_sets_incident_end_time(self): }, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") incident_1.refresh_from_db() incident_2.refresh_from_db() @@ -1250,7 +1250,7 @@ def test_bulk_reopen_removes_incident_end_time(self): }, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") incident_1.refresh_from_db() incident_2.refresh_from_db() @@ -1284,7 +1284,7 @@ def test_cannot_bulk_create_events_for_incidents_with_all_invalid_ids(self): "event": self.event_data, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1310,7 +1310,7 @@ def test_can_partially_bulk_create_events_for_incidents_with_some_valid_ids(self "event": self.event_data, } - response = self.client.post(path=f"/api/v2/incidents/events/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/events/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1348,7 +1348,7 @@ def test_can_bulk_set_ticket_url_for_incidents_with_valid_ids(self): "ticket_url": self.ticket_url, } - response = self.client.post(path=f"/api/v2/incidents/ticket_url/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/ticket_url/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -1376,7 +1376,7 @@ def test_cannot_bulk_set_ticket_url_for_incidents_with_all_invalid_ids(self): "ticket_url": self.ticket_url, } - response = self.client.post(path=f"/api/v2/incidents/ticket_url/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/ticket_url/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) @@ -1399,7 +1399,7 @@ def test_can_partially_bulk_set_ticket_url_for_incidents_with_some_valid_ids(sel "ticket_url": self.ticket_url, } - response = self.client.post(path=f"/api/v2/incidents/ticket_url/bulk/", data=data, format="json") + response = self.client.post(path="/api/v2/incidents/ticket_url/bulk/", data=data, format="json") self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/tests/notificationprofile/destinations/test_email.py b/tests/notificationprofile/destinations/test_email.py index a32c04333..5c332e20c 100644 --- a/tests/notificationprofile/destinations/test_email.py +++ b/tests/notificationprofile/destinations/test_email.py @@ -238,12 +238,12 @@ def test_should_get_json_schema_for_email(self): } } - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/email/json_schema/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/email/json_schema/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data, schema) def test_should_get_email_medium(self): - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/email/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/email/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data["name"], "Email") diff --git a/tests/notificationprofile/destinations/test_sms.py b/tests/notificationprofile/destinations/test_sms.py index 1ea34c2ad..4a16aef72 100644 --- a/tests/notificationprofile/destinations/test_sms.py +++ b/tests/notificationprofile/destinations/test_sms.py @@ -198,12 +198,12 @@ def test_should_get_json_schema_for_sms(self): } } - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/sms/json_schema/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/sms/json_schema/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data, schema) def test_should_get_sms_medium(self): - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/sms/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/sms/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data["name"], "SMS") diff --git a/tests/notificationprofile/test_views.py b/tests/notificationprofile/test_views.py index 86db895b8..08b5277b9 100644 --- a/tests/notificationprofile/test_views.py +++ b/tests/notificationprofile/test_views.py @@ -450,13 +450,13 @@ def teardown(self): connect_signals() def test_should_get_all_media(self): - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(len(response.data), 2) self.assertEqual(set([medium["slug"] for medium in response.data]), set(["sms", "email"])) def test_should_get_specific_medium(self): - response = self.user1_rest_client.get(path=f"/api/v2/notificationprofiles/media/email/") + response = self.user1_rest_client.get(path="/api/v2/notificationprofiles/media/email/") self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data["slug"], "email")