comparison test/rest_common.py @ 8094:8e310a7b5e09

issue2551131 - Return accept-patch if patch body not accepted (415 code) Now returns: Accept-Patch: application/json, application/x-www-form-urlencoded for PATCH verb.
author John Rouillard <rouilj@ieee.org>
date Tue, 16 Jul 2024 20:23:36 -0400
parents 171ff2e487df
children 2967f37e73e4
comparison
equal deleted inserted replaced
8093:d913db0ab498 8094:8e310a7b5e09
1805 print(results) 1805 print(results)
1806 self.assertEqual(self.server.client.response_code, 415) 1806 self.assertEqual(self.server.client.response_code, 415)
1807 json_dict = json.loads(b2s(results)) 1807 json_dict = json.loads(b2s(results))
1808 self.assertEqual(json_dict['error']['msg'], 1808 self.assertEqual(json_dict['error']['msg'],
1809 "Unable to process input of type application/jzot") 1809 "Unable to process input of type application/jzot")
1810 self.assertNotIn("Accept-Patch",
1811 self.server.client.additional_headers)
1812 self.server.client.additional_headers = {}
1813
1814
1815 # test with PATCH verb to verify Accept-Patch is correct
1816 results = self.server.dispatch("PATCH",
1817 "/rest/data/issue",
1818 form)
1819 self.assertEqual(self.server.client.response_code, 415)
1820 json_dict = json.loads(b2s(results))
1821 self.assertEqual(json_dict['error']['msg'],
1822 "Unable to process input of type application/jzot")
1823 self.assertIn("Accept-Patch",
1824 self.server.client.additional_headers)
1825 self.assertEqual(self.server.client.additional_headers["Accept-Patch"],
1826 "application/json, application/x-www-form-urlencoded" )
1827 self.server.client.additional_headers = {}
1810 1828
1811 # Test GET as well. I am not sure if this should pass or not. 1829 # Test GET as well. I am not sure if this should pass or not.
1812 # Arguably GET doesn't use any form/json input but.... 1830 # Arguably GET doesn't use any form/json input but....
1813 results = self.server.dispatch('GET', 1831 results = self.server.dispatch('GET',
1814 "/rest/data/issue", 1832 "/rest/data/issue",
1815 form) 1833 form)
1816 print(results) 1834 print(results)
1817 self.assertEqual(self.server.client.response_code, 415) 1835 self.assertEqual(self.server.client.response_code, 415)
1818 1836 self.assertNotIn("Accept-Patch",
1819 1837 self.server.client.additional_headers)
1838 self.server.client.additional_headers = {}
1820 1839
1821 def testDispatchBadAccept(self): 1840 def testDispatchBadAccept(self):
1822 # simulate: /rest/data/issue expect failure unknown accept settings 1841 # simulate: /rest/data/issue expect failure unknown accept settings
1823 body=b'{ "title": "Joe Doe has problems", \ 1842 body=b'{ "title": "Joe Doe has problems", \
1824 "nosy": [ "1", "3" ], \ 1843 "nosy": [ "1", "3" ], \

Roundup Issue Tracker: http://roundup-tracker.org/