@@ -185,27 +185,42 @@ def test_polymorphism_relations_update(single_company, research_project_factory,
185
185
"type" : "researchProjects" ,
186
186
"id" : research_project .pk
187
187
}
188
- response = client .put (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
189
- data = content )
188
+ response = client .patch (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
189
+ data = content )
190
190
assert response .status_code == 200
191
191
content = response .json ()
192
192
assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "researchProjects"
193
193
assert int (content ["data" ]["relationships" ]["currentProject" ]["data" ]["id" ]) == \
194
194
research_project .pk
195
195
196
196
197
- def test_invalid_type_on_polymorphic_relation (single_company , research_project_factory , client ):
197
+ def test_polymorphism_relations_put_405 (single_company , research_project_factory , client ):
198
198
response = client .get (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }))
199
199
content = response .json ()
200
200
assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "artProjects"
201
201
202
202
research_project = research_project_factory ()
203
203
content ["data" ]["relationships" ]["currentProject" ]["data" ] = {
204
- "type" : "invalidProjects " ,
204
+ "type" : "researchProjects " ,
205
205
"id" : research_project .pk
206
206
}
207
207
response = client .put (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
208
208
data = content )
209
+ assert response .status_code == 405
210
+
211
+
212
+ def test_invalid_type_on_polymorphic_relation (single_company , research_project_factory , client ):
213
+ response = client .get (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }))
214
+ content = response .json ()
215
+ assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "artProjects"
216
+
217
+ research_project = research_project_factory ()
218
+ content ["data" ]["relationships" ]["currentProject" ]["data" ] = {
219
+ "type" : "invalidProjects" ,
220
+ "id" : research_project .pk
221
+ }
222
+ response = client .patch (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
223
+ data = content )
209
224
assert response .status_code == 409
210
225
content = response .json ()
211
226
assert len (content ["errors" ]) == 1
0 commit comments