@@ -168,27 +168,42 @@ def test_polymorphism_relations_update(single_company, research_project_factory,
168168 "type" : "researchProjects" ,
169169 "id" : research_project .pk
170170 }
171- response = client .put (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
172- data = content )
171+ response = client .patch (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
172+ data = content )
173173 assert response .status_code == 200
174174 content = response .json ()
175175 assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "researchProjects"
176176 assert int (content ["data" ]["relationships" ]["currentProject" ]["data" ]["id" ]) == \
177177 research_project .pk
178178
179179
180- def test_invalid_type_on_polymorphic_relation (single_company , research_project_factory , client ):
180+ def test_polymorphism_relations_put_405 (single_company , research_project_factory , client ):
181181 response = client .get (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }))
182182 content = response .json ()
183183 assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "artProjects"
184184
185185 research_project = research_project_factory ()
186186 content ["data" ]["relationships" ]["currentProject" ]["data" ] = {
187- "type" : "invalidProjects " ,
187+ "type" : "researchProjects " ,
188188 "id" : research_project .pk
189189 }
190190 response = client .put (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
191191 data = content )
192+ assert response .status_code == 405
193+
194+
195+ def test_invalid_type_on_polymorphic_relation (single_company , research_project_factory , client ):
196+ response = client .get (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }))
197+ content = response .json ()
198+ assert content ["data" ]["relationships" ]["currentProject" ]["data" ]["type" ] == "artProjects"
199+
200+ research_project = research_project_factory ()
201+ content ["data" ]["relationships" ]["currentProject" ]["data" ] = {
202+ "type" : "invalidProjects" ,
203+ "id" : research_project .pk
204+ }
205+ response = client .patch (reverse ("company-detail" , kwargs = {'pk' : single_company .pk }),
206+ data = content )
192207 assert response .status_code == 409
193208 content = response .json ()
194209 assert len (content ["errors" ]) == 1
0 commit comments