Skip to content

Commit 386e28e

Browse files
committed
Test for xml response
1 parent e851680 commit 386e28e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/postmon_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,27 @@ class PostmonV1WebTest(PostmonWebTest):
168168
def get_cep(self, cep):
169169
response = self.app.get('/v1/cep/' + cep)
170170
return response.json
171+
172+
173+
class PostmonXMLTest(unittest.TestCase):
174+
""" testa requisições XML """
175+
176+
def setUp(self):
177+
self.app = webtest.TestApp(bottle.app())
178+
179+
def get_cep(self, cep):
180+
response = self.app.get(
181+
'/cep/%s?format=xml' % cep
182+
)
183+
return response
184+
185+
def test_xml_return(self):
186+
expected = ('<?xml version="1.0" encoding="utf-8"?>\n'
187+
'<result><bairro>Parque S\xc3\xa3o George</bairro>'
188+
'<cidade>Cotia</cidade>'
189+
'<cep>06708070</cep>'
190+
'<logradouro>Avenida Eid Mansur</logradouro>'
191+
'<estado>SP</estado></result>')
192+
193+
response = self.get_cep('06708070')
194+
self.assertEqual(response.body.strip(), expected.strip())

0 commit comments

Comments
 (0)