def test_get_raise_parse_error(self): self.urlfetch_mock.set_return_values(content="Not nice XML", status_code=200) api = appengine.AppEngineAPI() self.assertRaises(ElementTree.ParseError, api.get, 'eve/Error')
def test_get_raise_urlfetch_error(self): self.urlfetch_mock.set_return_values( content="This is not a pretty XML error.", status_code=400) api = appengine.AppEngineAPI() self.assertRaises(appengine.api.UrlFetchError, api.get, 'eve/Error')
def test_get_raise_api_error(self): self.urlfetch_mock.set_return_values(content=self.error_xml, status_code=400) api = appengine.AppEngineAPI() self.assertRaises(APIError, api.get, 'eve/Error') self.assertEqual(api.last_timestamps, { 'current_time': 1255885531, 'cached_until': 1258571131, })
def test_get_async(self): self.urlfetch_mock.set_return_values(content=self.test_xml, status_code=200) api = appengine.AppEngineAPI() result = api.get_async('foo/Bar', {'a': [1, 2, 3]}).get_result().result rowset = result.find('rowset') rows = rowset.findall('row') self.assertEqual(len(rows), 2) self.assertEqual(rows[0].attrib['foo'], 'bar') self.assertEqual(api.last_timestamps, { 'current_time': 1255885531, 'cached_until': 1258563931, })