Пример #1
0
    def test_check_service_status(self):

        plugins=[]
        check_class_name = 'CeleryHealthCheckCelery'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals({}, result)
        self.assertEquals(status, 500)

        #Все неработающие плагины (status=0)
        plugins = self._get_available_plugins(status=0)

        #Неизвесный plugin
        check_class_name = 'UnregistredInPluginsClassName'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals({}, result)
        self.assertEquals(status, 500)

        check_class_name = 'DatabaseBackend'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'unavailable'})
        self.assertEquals(status, 500500)

        check_class_name = 'RabbitMQHealthCheck'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'unavailable'})
        self.assertEquals(status, 500)

        check_class_name = 'CeleryHealthCheckCelery'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'unavailable'})
        self.assertEquals(status, 500)


        #Все активные плагины (status=1)
        plugins = self._get_available_plugins(status=1)

        check_class_name = 'DatabaseBackend'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'working'})
        self.assertEquals(status, 200)

        check_class_name = 'RabbitMQHealthCheck'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'working'})
        self.assertEquals(status, 200)

        check_class_name = 'CeleryHealthCheckCelery'
        result, status = check_service(check_class_name, plugins)
        self.assertEquals(result, {check_class_name: 'working'})
        self.assertEquals(status, 200)
Пример #2
0
 def render_to_response_json(self, plugins, status):
     check_class_name = 'RabbitMQHealthCheck'
     result, status = check_service(check_class_name, plugins)
     return JsonResponse(result, status=status)
Пример #3
0
 def render_to_response_json(self, plugins, status):
     check_class_name = 'CacheBackend'
     result, status = check_service(check_class_name, plugins)
     return JsonResponse(result, status=status)