コード例 #1
0
ファイル: test_middleware.py プロジェクト: laoyin/maas
    def test__checks_connectivity_of_rack_controllers(self):
        getAllClients = self.patch(middleware_module, 'getAllClients')

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        self.assertThat(getAllClients, MockCalledOnceWith())
コード例 #2
0
ファイル: test_middleware.py プロジェクト: laoyin/maas
    def test__registers_error_if_all_rack_controllers_are_disconnected(self):
        factory.make_RackController()

        getAllClients = self.patch(middleware_module, 'getAllClients')
        getAllClients.return_value = []

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        error = get_persistent_error(COMPONENT.RACK_CONTROLLERS)
        self.assertEqual(
            "One rack controller is not yet connected to the region. Visit "
            "the <a href=\"%s#/nodes?tab=controllers\">"
            "rack controllers page</a> for more "
            "information." % (reverse('index')), error)
コード例 #3
0
ファイル: test_middleware.py プロジェクト: laoyin/maas
 def test__does_not_suppress_exceptions_from_connectivity_checks(self):
     middleware = ExternalComponentsMiddleware()
     error_type = factory.make_exception_type()
     check_rack_controller_connectivity = self.patch(
         middleware, "_check_rack_controller_connectivity")
     check_rack_controller_connectivity.side_effect = error_type
     self.assertRaises(error_type, middleware.process_request, None)
     self.assertThat(check_rack_controller_connectivity,
                     MockCalledOnceWith())
コード例 #4
0
ファイル: test_middleware.py プロジェクト: laoyin/maas
    def test__removes_error_once_all_clusters_are_connected(self):
        rack_controllers = [
            factory.make_RackController(),
            factory.make_RackController(),
        ]

        getAllClients = self.patch(middleware_module, 'getAllClients')
        getAllClients.return_value = [
            Mock(ident=rack.system_id) for rack in rack_controllers
        ]

        register_persistent_error(COMPONENT.RACK_CONTROLLERS,
                                  "Who flung that batter pudding?")

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        error = get_persistent_error(COMPONENT.RACK_CONTROLLERS)
        self.assertIsNone(error)
コード例 #5
0
ファイル: test_middleware.py プロジェクト: zhangrb/maas
    def process_request(self, request):
        def get_response(request):
            return None

        middleware = ExternalComponentsMiddleware(get_response)
        return middleware(request)