@@ -76,15 +76,13 @@ def test_get_entry_relationship_blog(self):
7676
7777 def test_get_entry_relationship_invalid_field (self ):
7878 response = self .client .get (
79- "/entries/{}/relationships/invalid_field" . format ( self . first_entry . id )
79+ f "/entries/{ self . first_entry . id } /relationships/invalid_field"
8080 )
8181
8282 assert response .status_code == 404
8383
8484 def test_get_blog_relationship_entry_set (self ):
85- response = self .client .get (
86- "/blogs/{}/relationships/entry_set" .format (self .blog .id )
87- )
85+ response = self .client .get (f"/blogs/{ self .blog .id } /relationships/entry_set" )
8886 expected_data = [
8987 {"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
9088 {"type" : format_resource_type ("Entry" ), "id" : str (self .second_entry .id )},
@@ -94,9 +92,7 @@ def test_get_blog_relationship_entry_set(self):
9492
9593 @override_settings (JSON_API_FORMAT_RELATED_LINKS = "dasherize" )
9694 def test_get_blog_relationship_entry_set_with_formatted_link (self ):
97- response = self .client .get (
98- "/blogs/{}/relationships/entry-set" .format (self .blog .id )
99- )
95+ response = self .client .get (f"/blogs/{ self .blog .id } /relationships/entry-set" )
10096 expected_data = [
10197 {"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
10298 {"type" : format_resource_type ("Entry" ), "id" : str (self .second_entry .id )},
@@ -105,17 +101,17 @@ def test_get_blog_relationship_entry_set_with_formatted_link(self):
105101 assert response .data == expected_data
106102
107103 def test_put_entry_relationship_blog_returns_405 (self ):
108- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
104+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
109105 response = self .client .put (url , data = {})
110106 assert response .status_code == 405
111107
112108 def test_patch_invalid_entry_relationship_blog_returns_400 (self ):
113- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
109+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
114110 response = self .client .patch (url , data = {"data" : {"invalid" : "" }})
115111 assert response .status_code == 400
116112
117113 def test_relationship_view_errors_format (self ):
118- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
114+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
119115 response = self .client .patch (url , data = {"data" : {"invalid" : "" }})
120116 assert response .status_code == 400
121117
@@ -125,14 +121,14 @@ def test_relationship_view_errors_format(self):
125121 assert "errors" in result
126122
127123 def test_get_empty_to_one_relationship (self ):
128- url = "/comments/{}/relationships/author" . format ( self . first_entry . id )
124+ url = f "/comments/{ self . first_entry . id } /relationships/author"
129125 response = self .client .get (url )
130126 expected_data = None
131127
132128 assert response .data == expected_data
133129
134130 def test_get_to_many_relationship_self_link (self ):
135- url = "/authors/{}/relationships/comments" . format ( self . author . id )
131+ url = f "/authors/{ self . author . id } /relationships/comments"
136132
137133 response = self .client .get (url )
138134 expected_data = {
@@ -147,7 +143,7 @@ def test_get_to_many_relationship_self_link(self):
147143 assert json .loads (response .content .decode ("utf-8" )) == expected_data
148144
149145 def test_patch_to_one_relationship (self ):
150- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
146+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
151147 request_data = {
152148 "data" : {
153149 "type" : format_resource_type ("Blog" ),
@@ -162,7 +158,7 @@ def test_patch_to_one_relationship(self):
162158 assert response .data == request_data ["data" ]
163159
164160 def test_patch_one_to_many_relationship (self ):
165- url = "/blogs/{}/relationships/entry_set" . format ( self . first_entry . id )
161+ url = f "/blogs/{ self . first_entry . id } /relationships/entry_set"
166162 request_data = {
167163 "data" : [
168164 {"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
@@ -184,7 +180,7 @@ def test_patch_one_to_many_relationship(self):
184180 assert response .data == request_data ["data" ]
185181
186182 def test_patch_one_to_many_relaitonship_with_none (self ):
187- url = "/blogs/{}/relationships/entry_set" . format ( self . first_entry . id )
183+ url = f "/blogs/{ self . first_entry . id } /relationships/entry_set"
188184 request_data = {"data" : None }
189185 response = self .client .patch (url , data = request_data )
190186 assert response .status_code == 200 , response .content .decode ()
@@ -194,7 +190,7 @@ def test_patch_one_to_many_relaitonship_with_none(self):
194190 assert response .data == []
195191
196192 def test_patch_many_to_many_relationship (self ):
197- url = "/entries/{}/relationships/authors" . format ( self . first_entry . id )
193+ url = f "/entries/{ self . first_entry . id } /relationships/authors"
198194 request_data = {
199195 "data" : [
200196 {"type" : format_resource_type ("Author" ), "id" : str (self .author .id )},
@@ -216,7 +212,7 @@ def test_patch_many_to_many_relationship(self):
216212 assert response .data == request_data ["data" ]
217213
218214 def test_post_to_one_relationship_should_fail (self ):
219- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
215+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
220216 request_data = {
221217 "data" : {
222218 "type" : format_resource_type ("Blog" ),
@@ -227,7 +223,7 @@ def test_post_to_one_relationship_should_fail(self):
227223 assert response .status_code == 405 , response .content .decode ()
228224
229225 def test_post_to_many_relationship_with_no_change (self ):
230- url = "/entries/{}/relationships/comments" . format ( self . first_entry . id )
226+ url = f "/entries/{ self . first_entry . id } /relationships/comments"
231227 request_data = {
232228 "data" : [
233229 {
@@ -241,7 +237,7 @@ def test_post_to_many_relationship_with_no_change(self):
241237 assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
242238
243239 def test_post_to_many_relationship_with_change (self ):
244- url = "/entries/{}/relationships/comments" . format ( self . first_entry . id )
240+ url = f "/entries/{ self . first_entry . id } /relationships/comments"
245241 request_data = {
246242 "data" : [
247243 {
@@ -256,7 +252,7 @@ def test_post_to_many_relationship_with_change(self):
256252 assert request_data ["data" ][0 ] in response .data
257253
258254 def test_delete_to_one_relationship_should_fail (self ):
259- url = "/entries/{}/relationships/blog" . format ( self . first_entry . id )
255+ url = f "/entries/{ self . first_entry . id } /relationships/blog"
260256 request_data = {
261257 "data" : {
262258 "type" : format_resource_type ("Blog" ),
@@ -267,7 +263,7 @@ def test_delete_to_one_relationship_should_fail(self):
267263 assert response .status_code == 405 , response .content .decode ()
268264
269265 def test_delete_relationship_overriding_with_none (self ):
270- url = "/comments/{}" . format ( self .second_comment .id )
266+ url = f "/comments/{ self .second_comment .id } "
271267 request_data = {
272268 "data" : {
273269 "type" : "comments" ,
@@ -280,7 +276,7 @@ def test_delete_relationship_overriding_with_none(self):
280276 assert response .data ["author" ] is None
281277
282278 def test_delete_to_many_relationship_with_no_change (self ):
283- url = "/entries/{}/relationships/comments" . format ( self . first_entry . id )
279+ url = f "/entries/{ self . first_entry . id } /relationships/comments"
284280 request_data = {
285281 "data" : [
286282 {
@@ -294,7 +290,7 @@ def test_delete_to_many_relationship_with_no_change(self):
294290 assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
295291
296292 def test_delete_one_to_many_relationship_with_not_null_constraint (self ):
297- url = "/entries/{}/relationships/comments" . format ( self . first_entry . id )
293+ url = f "/entries/{ self . first_entry . id } /relationships/comments"
298294 request_data = {
299295 "data" : [
300296 {
@@ -307,7 +303,7 @@ def test_delete_one_to_many_relationship_with_not_null_constraint(self):
307303 assert response .status_code == 409 , response .content .decode ()
308304
309305 def test_delete_to_many_relationship_with_change (self ):
310- url = "/authors/{}/relationships/comments" . format ( self . author . id )
306+ url = f "/authors/{ self . author . id } /relationships/comments"
311307 request_data = {
312308 "data" : [
313309 {
@@ -323,7 +319,7 @@ def test_new_comment_data_patch_to_many_relationship(self):
323319 entry = EntryFactory (blog = self .blog , authors = (self .author ,))
324320 comment = CommentFactory (entry = entry )
325321
326- url = "/authors/{}/relationships/comments" . format ( self . author . id )
322+ url = f "/authors/{ self . author . id } /relationships/comments"
327323 request_data = {
328324 "data" : [
329325 {"type" : format_resource_type ("Comment" ), "id" : str (comment .id )},
@@ -597,7 +593,7 @@ def setUp(self):
597593 self .blog = Blog .objects .create (name = "Some Blog" , tagline = "It's a blog" )
598594
599595 def test_no_content_response (self ):
600- url = "/blogs/{}" . format ( self .blog .pk )
596+ url = f "/blogs/{ self .blog .pk } "
601597 response = self .client .delete (url )
602598 assert response .status_code == 204 , response .rendered_content .decode ()
603599 assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
@@ -618,8 +614,8 @@ def test_get_object_gives_correct_blog(self):
618614 expected = {
619615 "data" : {
620616 "attributes" : {"name" : self .blog .name },
621- "id" : "{}" . format ( self .blog .id ) ,
622- "links" : {"self" : "http://testserver/blogs/{}" . format ( self .blog .id ) },
617+ "id" : f" { self .blog .id } " ,
618+ "links" : {"self" : f "http://testserver/blogs/{ self .blog .id } " },
623619 "meta" : {"copyright" : datetime .now ().year },
624620 "relationships" : {"tags" : {"data" : [], "meta" : {"count" : 0 }}},
625621 "type" : "blogs" ,
@@ -656,13 +652,13 @@ def test_get_object_gives_correct_entry(self):
656652 "modDate" : self .second_entry .mod_date ,
657653 "pubDate" : self .second_entry .pub_date ,
658654 },
659- "id" : "{}" . format ( self .second_entry .id ) ,
655+ "id" : f" { self .second_entry .id } " ,
660656 "meta" : {"bodyFormat" : "text" },
661657 "relationships" : {
662658 "authors" : {"data" : [], "meta" : {"count" : 0 }},
663659 "blog" : {
664660 "data" : {
665- "id" : "{}" . format ( self .second_entry .blog_id ) ,
661+ "id" : f" { self .second_entry .blog_id } " ,
666662 "type" : "blogs" ,
667663 }
668664 },
0 commit comments