Ejemplo n.º 1
0
    def test_handle_request_error(self):
        func = MagicMock()
        func.side_effect = ValueError("Test error")
        m = Method("test_method", "test_description")
        m.set_function(func)
        m.takes = MagicMock()
        m.returns = MagicMock()
        request = MagicMock()

        m.handle_request(request)

        request.respond_with_error.assert_called_once_with(
            "Method test_method raised an error: Test error")
Ejemplo n.º 2
0
    def test_handle_request_error(self):
        func = MagicMock()
        func.side_effect = ValueError("Test error")
        m = Method("test_method", "test_description")
        m.set_function(func)
        m.takes = MagicMock()
        m.returns = MagicMock()
        request = MagicMock()

        m.handle_request(request)

        request.respond_with_error.assert_called_once_with(
            "Method test_method raised an error: Test error")
Ejemplo n.º 3
0
    def test_get_response_raises(self):
        func = MagicMock()
        func.side_effect = ValueError("Test error")
        m = Method("test_description")
        m.set_parent(Mock(), "test_method")
        m.set_function(func)
        m.takes = MagicMock()
        m.returns = MagicMock()
        request = MagicMock()

        response = m.get_response(request)
        self.assertEquals("malcolm:core/Error:1.0", response.typeid)
        self.assertEquals("Method test_method raised an error: Test error",
                          response.message)
Ejemplo n.º 4
0
    def test_get_response_raises(self):
        func = MagicMock()
        func.side_effect = ValueError("Test error")
        m = Method("test_description")
        m.set_parent(Mock(), "test_method")
        m.set_function(func)
        m.takes = MagicMock()
        m.returns = MagicMock()
        request = MagicMock()

        response = m.get_response(request)
        self.assertEquals("malcolm:core/Error:1.0", response.typeid)
        self.assertEquals(
            "Method test_method raised an error: Test error", response.message)