예제 #1
0
파일: test_views.py 프로젝트: sau29/scale
    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)
예제 #2
0
    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))
예제 #3
0
    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)
예제 #4
0
    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})