Esempio n. 1
0
 def test_invalid_json(self):
     self.response.content = '{"this:"is", "json":true}'
     resp = APIResponseWrapper(response=self.response)
     #because its a property you have to make it a function
     self.assertRaises(
         ValueError,
         lambda: resp.json,
     )
Esempio n. 2
0
 def test_invalid_xml(self):
     self.response.content = self.XML[:50]
     resp = APIResponseWrapper(response=self.response)
     self.assertRaises(ValueError, lambda: resp.xml)
Esempio n. 3
0
 def test_xml(self):
     self.response.content = self.XML
     resp = APIResponseWrapper(response=self.response)
     title = resp.xml.getchildren()[0].getchildren()[0].text
     self.assertEquals(title, 'Whoops - Pivotal Tracker')
Esempio n. 4
0
 def test_json(self):
     self.response.content = '{"this":"is", "json":true}'
     print self.response.content
     resp = APIResponseWrapper(response=self.response)
     self.assertEquals(json.loads(self.response.content), resp.json)