コード例 #1
0
    def test_call_wrapper_404(self):
        full_url = self.url % '404'
        with requests_mock.mock() as m:
            m.get(full_url, text='', status_code=404)

            with self.assertRaises(IOError):
                _call_wrapper(full_url)
コード例 #2
0
    def test_call_wrapper_invalid_request(self):
        full_url = self.url % 'invalid'
        with requests_mock.mock() as m:
            m.get(full_url, text=invalid_request)

            with self.assertRaises(GoogleAPIInvalidRequest):
                _call_wrapper(full_url)
コード例 #3
0
    def test_call_wrapper_unknown_error(self):
        full_url = self.url % 'unknown'
        with requests_mock.mock() as m:
            m.get(full_url, text=unknown_error)

            with self.assertRaises(IOError):
                _call_wrapper(full_url)
コード例 #4
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_unknown_error(self):
        full_url = self.url % 'unknown'
        with requests_mock.mock() as m:
            m.get(full_url, text=unknown_error)

            with self.assertRaises(IOError):
                _call_wrapper(full_url)
コード例 #5
0
    def test_call_wrapper_request_denied(self):
        full_url = self.url % 'denied'
        with requests_mock.mock() as m:
            m.get(full_url, text=request_denied)

            with self.assertRaises(GoogleAPIRequestDenied):
                _call_wrapper(full_url)
コード例 #6
0
    def test_call_wrapper_exceeded_limit(self):
        full_url = self.url % 'exceeded'
        with requests_mock.mock() as m:
            m.get(full_url, text=over_query_limit)

            with self.assertRaises(GoogleAPILimitExceeded):
                _call_wrapper(full_url)
コード例 #7
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_404(self):
        full_url = self.url % '404'
        with requests_mock.mock() as m:
            m.get(full_url, text='', status_code=404)

            with self.assertRaises(IOError):
                _call_wrapper(full_url)
コード例 #8
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_invalid_request(self):
        full_url = self.url % 'invalid'
        with requests_mock.mock() as m:
            m.get(full_url, text=invalid_request)

            with self.assertRaises(GoogleAPIInvalidRequest):
                _call_wrapper(full_url)
コード例 #9
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_request_denied(self):
        full_url = self.url % 'denied'
        with requests_mock.mock() as m:
            m.get(full_url, text=request_denied)

            with self.assertRaises(GoogleAPIRequestDenied):
                _call_wrapper(full_url)
コード例 #10
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_exceeded_limit(self):
        full_url = self.url % 'exceeded'
        with requests_mock.mock() as m:
            m.get(full_url, text=over_query_limit)

            with self.assertRaises(GoogleAPILimitExceeded):
                _call_wrapper(full_url)
コード例 #11
0
    def test_call_wrapper_zero_results(self):
        full_url = self.url % 'zero'
        with requests_mock.mock() as m:
            m.get(full_url, text=zero_results)

            obs = _call_wrapper(full_url)
            self.assertEqual(obs, {})
コード例 #12
0
 def test_call_wrapper_ok(self):
     full_url = self.url % 'ok'
     with requests_mock.mock() as m:
         m.get(full_url, text=ok)
         obs = _call_wrapper(full_url)
     exp = loads(ok)['results']
     self.assertEqual(obs, exp)
コード例 #13
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
    def test_call_wrapper_zero_results(self):
        full_url = self.url % 'zero'
        with requests_mock.mock() as m:
            m.get(full_url, text=zero_results)

            obs = _call_wrapper(full_url)
            self.assertEqual(obs, {})
コード例 #14
0
ファイル: test_geocoder.py プロジェクト: biocore/labadmin
 def test_call_wrapper_ok(self):
     full_url = self.url % 'ok'
     with requests_mock.mock() as m:
         m.get(full_url, text=ok)
         obs = _call_wrapper(full_url)
     exp = loads(ok)['results']
     self.assertEqual(obs, exp)