예제 #1
0
 def test_get_statistic__status_500(self, r_mock):
     m_resp = mock.Mock(r.Response)
     m_resp.status_code = 500
     m_resp.url = 'http://url'
     m_resp.reason = 'reason 500'
     r_mock.return_value = m_resp
     with self.assertRaises(ServiceException):
         get_statistic(self.test_agency_cd, self.test_site_no, 'site-info',
                       self.test_service_root)
예제 #2
0
 def test_get_statistic__status_404(self, r_mock):
     m_resp = mock.Mock(r.Response)
     m_resp.status_code = 404
     m_resp.url = self.test_service_root
     m_resp.reason = 'reason 404'
     r_mock.return_value = m_resp
     result = get_statistic(self.test_agency_cd, self.test_site_no,
                            'site-info', self.test_service_root)
     self.assertEqual(False, result['is_fetched'])
     self.assertEqual(False, result['is_ranked'])
예제 #3
0
 def test_get_statistic__success(self, r_mock):
     m_resp = mock.Mock(r.Response)
     m_resp.text = '{"value":"SUCCESS"}'
     m_resp.status_code = 200
     m_resp.url = self.test_service_root
     r_mock.return_value = m_resp
     result = get_statistic(self.test_agency_cd, self.test_site_no,
                            'site-info', self.test_service_root)
     self.assertEqual('SUCCESS', result['value'])
     self.assertEqual(True, result['is_fetched'])
     url = '/'.join([
         self.test_service_root, 'ngwmn_cache/direct/json/site-info',
         self.test_agency_cd, self.test_site_no
     ])
     r_mock.assert_called_with(url)