Skip to content

Commit

Permalink
Remove f-string without any placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Nov 28, 2024
1 parent a4f9096 commit 034ebaf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/argus/incident/V1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/argus/incident/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/dev/test_create_fake_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand 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)

Expand Down
2 changes: 1 addition & 1 deletion tests/dev/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down
48 changes: 24 additions & 24 deletions tests/incident/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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])
Expand All @@ -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())

Expand Down Expand Up @@ -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"
Expand All @@ -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])
Expand All @@ -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])
Expand All @@ -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())

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/notificationprofile/destinations/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions tests/notificationprofile/destinations/test_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions tests/notificationprofile/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 034ebaf

Please sign in to comment.