def test_status_old(self): """Test getting scheduler status with old data""" when = now() - datetime.timedelta(hours=1) status_thread = SchedulerStatusThread() status_thread._generate_status_json(when) url = '/%s/status/' % self.api response = self.client.generic('GET', url) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT, response.content)
def test_status_successful(self): """Test getting scheduler status successfully""" when = now() status_thread = SchedulerStatusThread() status_thread._generate_status_json(when) # url = rest_util.get_url('/status/') url = '/v5/status/' response = self.client.generic('GET', url) self.assertEqual(response.status_code, status.HTTP_200_OK, response.content) result = json.loads(response.content) self.assertEqual(result['timestamp'], datetime_to_string(when))
def test_status_old(self, mock_get_queue_size): """Test getting scheduler status with old data""" mock_get_queue_size.return_value = 0 when = now() - datetime.timedelta(hours=1) status_thread = SchedulerStatusThread() status_thread._generate_status_json(when) url = '/%s/status/' % self.api response = self.client.generic('GET', url) self.assertEqual(response.status_code, status.HTTP_503_SERVICE_UNAVAILABLE, response.content) result = json.loads(response.content) self.assertDictEqual({'detail': 'Status is over 12 seconds old'}, result)
def test_status_successful(self, mock_get_queue_size): """Test getting scheduler status successfully""" mock_get_queue_size.return_value = 0 when = now() status_thread = SchedulerStatusThread() status_thread._generate_status_json(when) url = '/%s/status/' % self.api response = self.client.generic('GET', url) self.assertEqual(response.status_code, status.HTTP_200_OK, response.content) result = json.loads(response.content) self.assertEqual(result['timestamp'], datetime_to_string(when)) self.assertDictEqual(result['vault'], {u'status': u'Secrets Not Configured', u'message': u'', u'sealed': False})