@@ -1778,6 +1778,80 @@ def test_post_tags_created_datetime(self, spec):
17781778 assert response_result .data .rootCause == rootCause
17791779 assert response_result .data .additionalinfo == additionalinfo
17801780
1781+ def test_post_tags_urlencoded (self , spec ):
1782+ host_url = "http://petstore.swagger.io/v1"
1783+ path_pattern = "/v1/tags"
1784+ created = "2016-04-16T16:06:05Z"
1785+ pet_name = "Dog"
1786+ data_json = {
1787+ "created" : created ,
1788+ "name" : pet_name ,
1789+ }
1790+ data = urlencode (data_json )
1791+ content_type = "application/x-www-form-urlencoded"
1792+
1793+ request = MockRequest (
1794+ host_url ,
1795+ "POST" ,
1796+ "/tags" ,
1797+ path_pattern = path_pattern ,
1798+ data = data ,
1799+ content_type = content_type ,
1800+ )
1801+
1802+ result = unmarshal_request (
1803+ request ,
1804+ spec = spec ,
1805+ cls = V30RequestParametersUnmarshaller ,
1806+ )
1807+
1808+ assert result .parameters == Parameters ()
1809+
1810+ result = unmarshal_request (
1811+ request , spec = spec , cls = V30RequestBodyUnmarshaller
1812+ )
1813+
1814+ assert is_dataclass (result .body )
1815+ assert result .body .created == datetime (
1816+ 2016 , 4 , 16 , 16 , 6 , 5 , tzinfo = UTC
1817+ )
1818+ assert result .body .name == pet_name
1819+
1820+ code = 400
1821+ message = "Bad request"
1822+ rootCause = "Tag already exist"
1823+ additionalinfo = "Tag Dog already exist"
1824+ response_data_json = {
1825+ "code" : code ,
1826+ "message" : message ,
1827+ "rootCause" : rootCause ,
1828+ "additionalinfo" : additionalinfo ,
1829+ }
1830+ response_data = json .dumps (response_data_json )
1831+ response = MockResponse (response_data , status_code = 404 )
1832+
1833+ result = unmarshal_response (
1834+ request ,
1835+ response ,
1836+ spec = spec ,
1837+ cls = V30ResponseDataUnmarshaller ,
1838+ )
1839+
1840+ assert is_dataclass (result .data )
1841+ assert result .data .code == code
1842+ assert result .data .message == message
1843+ assert result .data .rootCause == rootCause
1844+ assert result .data .additionalinfo == additionalinfo
1845+
1846+ response_result = unmarshal_response (request , response , spec = spec )
1847+
1848+ assert response_result .errors == []
1849+ assert is_dataclass (response_result .data )
1850+ assert response_result .data .code == code
1851+ assert response_result .data .message == message
1852+ assert response_result .data .rootCause == rootCause
1853+ assert response_result .data .additionalinfo == additionalinfo
1854+
17811855 def test_post_tags_created_invalid_type (self , spec ):
17821856 host_url = "http://petstore.swagger.io/v1"
17831857 path_pattern = "/v1/tags"
0 commit comments