@@ -185,27 +185,42 @@ def test_polymorphism_relations_update(single_company, research_project_factory,
185185 "type" : "researchProjects" ,
186186 "id" : research_project .pk
187187 }
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 )
190190 assert response .status_code == 200
191191 content = response .json ()
192192 assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "researchProjects"
193193 assert int (content ["data" ]["relationships" ]["currentProject" ]["data" ]["id" ]) == \
194194 research_project .pk
195195
196196
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 ):
198198 response = client .get (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }))
199199 content = response .json ()
200200 assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "artProjects"
201201
202202 research_project = research_project_factory ()
203203 content ["data" ]["relationships" ]["currentProject" ]["data" ] = {
204- "type" : "invalidProjects " ,
204+ "type" : "researchProjects " ,
205205 "id" : research_project .pk
206206 }
207207 response = client .put (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
208208 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 )
209224 assert response .status_code == 409
210225 content = response .json ()
211226 assert len (content ["errors" ]) == 1
0 commit comments