示例#1
0
文件: test_api.py 项目: ggrog/evelink
    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')
示例#2
0
文件: test_api.py 项目: ggrog/evelink
    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')
示例#3
0
文件: test_api.py 项目: ggrog/evelink
    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,
        })
示例#4
0
文件: test_api.py 项目: ggrog/evelink
    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,
        })