def test_check_client_not_found(self): self.tracker_manager.check_connection = MagicMock(side_effect=KeyError) client = TrackerCheck(self.tracker_manager) client.__no_auth__ = True self.api.add_route('/api/trackers/{tracker}/check', client) self.simulate_request('/api/trackers/{0}/check'.format('tracker.org')) self.assertEqual(self.srmock.status, falcon.HTTP_NOT_FOUND)
def test_check_client(self, value): self.tracker_manager.check_connection = MagicMock(return_value=value) client = TrackerCheck(self.tracker_manager) client.__no_auth__ = True self.api.add_route('/api/trackers/{tracker}/check', client) body = self.simulate_request('/api/trackers/{0}/check'.format('tracker.org'), decode='utf-8') self.assertEqual(self.srmock.status, falcon.HTTP_OK) self.assertTrue('application/json' in self.srmock.headers_dict['Content-Type']) result = json.loads(body) self.assertIsInstance(result, dict) self.assertEqual(result, {'status': value})
def test_check_client(self, value): self.tracker_manager.check_connection = MagicMock(return_value=value) client = TrackerCheck(self.tracker_manager) client.__no_auth__ = True self.api.add_route('/api/trackers/{tracker}/check', client) body = self.simulate_request( '/api/trackers/{0}/check'.format('tracker.org'), decode='utf-8') self.assertEqual(self.srmock.status, falcon.HTTP_OK) self.assertTrue( 'application/json' in self.srmock.headers_dict['Content-Type']) result = json.loads(body) self.assertIsInstance(result, dict) self.assertEqual(result, {'status': value})