@@ -76,15 +76,13 @@ def test_get_entry_relationship_blog(self):
76
76
77
77
def test_get_entry_relationship_invalid_field (self ):
78
78
response = self .client .get (
79
- "/entries/{}/relationships/invalid_field" . format ( self . first_entry . id )
79
+ f "/entries/{ self . first_entry . id } /relationships/invalid_field"
80
80
)
81
81
82
82
assert response .status_code == 404
83
83
84
84
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" )
88
86
expected_data = [
89
87
{"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
90
88
{"type" : format_resource_type ("Entry" ), "id" : str (self .second_entry .id )},
@@ -94,9 +92,7 @@ def test_get_blog_relationship_entry_set(self):
94
92
95
93
@override_settings (JSON_API_FORMAT_RELATED_LINKS = "dasherize" )
96
94
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" )
100
96
expected_data = [
101
97
{"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
102
98
{"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):
105
101
assert response .data == expected_data
106
102
107
103
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"
109
105
response = self .client .put (url , data = {})
110
106
assert response .status_code == 405
111
107
112
108
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"
114
110
response = self .client .patch (url , data = {"data" : {"invalid" : "" }})
115
111
assert response .status_code == 400
116
112
117
113
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"
119
115
response = self .client .patch (url , data = {"data" : {"invalid" : "" }})
120
116
assert response .status_code == 400
121
117
@@ -125,14 +121,14 @@ def test_relationship_view_errors_format(self):
125
121
assert "errors" in result
126
122
127
123
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"
129
125
response = self .client .get (url )
130
126
expected_data = None
131
127
132
128
assert response .data == expected_data
133
129
134
130
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"
136
132
137
133
response = self .client .get (url )
138
134
expected_data = {
@@ -147,7 +143,7 @@ def test_get_to_many_relationship_self_link(self):
147
143
assert json .loads (response .content .decode ("utf-8" )) == expected_data
148
144
149
145
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"
151
147
request_data = {
152
148
"data" : {
153
149
"type" : format_resource_type ("Blog" ),
@@ -162,7 +158,7 @@ def test_patch_to_one_relationship(self):
162
158
assert response .data == request_data ["data" ]
163
159
164
160
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"
166
162
request_data = {
167
163
"data" : [
168
164
{"type" : format_resource_type ("Entry" ), "id" : str (self .first_entry .id )},
@@ -184,7 +180,7 @@ def test_patch_one_to_many_relationship(self):
184
180
assert response .data == request_data ["data" ]
185
181
186
182
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"
188
184
request_data = {"data" : None }
189
185
response = self .client .patch (url , data = request_data )
190
186
assert response .status_code == 200 , response .content .decode ()
@@ -194,7 +190,7 @@ def test_patch_one_to_many_relaitonship_with_none(self):
194
190
assert response .data == []
195
191
196
192
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"
198
194
request_data = {
199
195
"data" : [
200
196
{"type" : format_resource_type ("Author" ), "id" : str (self .author .id )},
@@ -216,7 +212,7 @@ def test_patch_many_to_many_relationship(self):
216
212
assert response .data == request_data ["data" ]
217
213
218
214
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"
220
216
request_data = {
221
217
"data" : {
222
218
"type" : format_resource_type ("Blog" ),
@@ -227,7 +223,7 @@ def test_post_to_one_relationship_should_fail(self):
227
223
assert response .status_code == 405 , response .content .decode ()
228
224
229
225
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"
231
227
request_data = {
232
228
"data" : [
233
229
{
@@ -241,7 +237,7 @@ def test_post_to_many_relationship_with_no_change(self):
241
237
assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
242
238
243
239
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"
245
241
request_data = {
246
242
"data" : [
247
243
{
@@ -256,7 +252,7 @@ def test_post_to_many_relationship_with_change(self):
256
252
assert request_data ["data" ][0 ] in response .data
257
253
258
254
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"
260
256
request_data = {
261
257
"data" : {
262
258
"type" : format_resource_type ("Blog" ),
@@ -267,7 +263,7 @@ def test_delete_to_one_relationship_should_fail(self):
267
263
assert response .status_code == 405 , response .content .decode ()
268
264
269
265
def test_delete_relationship_overriding_with_none (self ):
270
- url = "/comments/{}" . format ( self .second_comment .id )
266
+ url = f "/comments/{ self .second_comment .id } "
271
267
request_data = {
272
268
"data" : {
273
269
"type" : "comments" ,
@@ -280,7 +276,7 @@ def test_delete_relationship_overriding_with_none(self):
280
276
assert response .data ["author" ] is None
281
277
282
278
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"
284
280
request_data = {
285
281
"data" : [
286
282
{
@@ -294,7 +290,7 @@ def test_delete_to_many_relationship_with_no_change(self):
294
290
assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
295
291
296
292
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"
298
294
request_data = {
299
295
"data" : [
300
296
{
@@ -307,7 +303,7 @@ def test_delete_one_to_many_relationship_with_not_null_constraint(self):
307
303
assert response .status_code == 409 , response .content .decode ()
308
304
309
305
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"
311
307
request_data = {
312
308
"data" : [
313
309
{
@@ -323,7 +319,7 @@ def test_new_comment_data_patch_to_many_relationship(self):
323
319
entry = EntryFactory (blog = self .blog , authors = (self .author ,))
324
320
comment = CommentFactory (entry = entry )
325
321
326
- url = "/authors/{}/relationships/comments" . format ( self . author . id )
322
+ url = f "/authors/{ self . author . id } /relationships/comments"
327
323
request_data = {
328
324
"data" : [
329
325
{"type" : format_resource_type ("Comment" ), "id" : str (comment .id )},
@@ -597,7 +593,7 @@ def setUp(self):
597
593
self .blog = Blog .objects .create (name = "Some Blog" , tagline = "It's a blog" )
598
594
599
595
def test_no_content_response (self ):
600
- url = "/blogs/{}" . format ( self .blog .pk )
596
+ url = f "/blogs/{ self .blog .pk } "
601
597
response = self .client .delete (url )
602
598
assert response .status_code == 204 , response .rendered_content .decode ()
603
599
assert len (response .rendered_content ) == 0 , response .rendered_content .decode ()
@@ -618,8 +614,8 @@ def test_get_object_gives_correct_blog(self):
618
614
expected = {
619
615
"data" : {
620
616
"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 } " },
623
619
"meta" : {"copyright" : datetime .now ().year },
624
620
"relationships" : {"tags" : {"data" : [], "meta" : {"count" : 0 }}},
625
621
"type" : "blogs" ,
@@ -656,13 +652,13 @@ def test_get_object_gives_correct_entry(self):
656
652
"modDate" : self .second_entry .mod_date ,
657
653
"pubDate" : self .second_entry .pub_date ,
658
654
},
659
- "id" : "{}" . format ( self .second_entry .id ) ,
655
+ "id" : f" { self .second_entry .id } " ,
660
656
"meta" : {"bodyFormat" : "text" },
661
657
"relationships" : {
662
658
"authors" : {"data" : [], "meta" : {"count" : 0 }},
663
659
"blog" : {
664
660
"data" : {
665
- "id" : "{}" . format ( self .second_entry .blog_id ) ,
661
+ "id" : f" { self .second_entry .blog_id } " ,
666
662
"type" : "blogs" ,
667
663
}
668
664
},
0 commit comments