def test_invoke_url_exception(self, invoker=None):
        '''This test case ensures invoke url internal exceptions are converted to concrete exceptions.'''

        app = Mock(side_effect=Exception("Unexpected exception"))

        if not invoker:
            invoker = FantasticoUrlInternalInvoker(app, self._wsgi_environ)

        invoker._app = app

        with self.assertRaises(FantasticoUrlInvokerError) as ex_ctx:
            invoker.invoke_url("/simle/url", [])

        self.assertTrue(str(ex_ctx.exception).find("Unexpected exception") > -1)

        return invoker
    def test_invoke_url_exception(self, invoker=None):
        '''This test case ensures invoke url internal exceptions are converted to concrete exceptions.'''

        app = Mock(side_effect=Exception("Unexpected exception"))

        if not invoker:
            invoker = FantasticoUrlInternalInvoker(app, self._wsgi_environ)

        invoker._app = app

        with self.assertRaises(FantasticoUrlInvokerError) as ex_ctx:
            invoker.invoke_url("/simle/url", [])

        self.assertTrue(
            str(ex_ctx.exception).find("Unexpected exception") > -1)

        return invoker
    def test_invoke_url_ok(self):
        '''This test case ensures invoke url works as expected.'''

        expected_response = ["simple response body"]
        expected_headers = [("CONTENT-TYPE", "application/json")]

        url = "/simple/url"
        headers = [("HTTP_CONTENT_TYPE", "application/json")]

        app = self._get_mock_app(self._wsgi_environ, expected_response, expected_headers)

        invoker = FantasticoUrlInternalInvoker(app, self._wsgi_environ)

        response = invoker.invoke_url(url, headers)

        self.assertEqual(expected_response, response)
        self.assertEqual(200, invoker.http_status)
        self.assertEqual(expected_headers, invoker.http_headers)

        return invoker
    def test_invoke_url_ok(self):
        '''This test case ensures invoke url works as expected.'''

        expected_response = ["simple response body"]
        expected_headers = [("CONTENT-TYPE", "application/json")]

        url = "/simple/url"
        headers = [("HTTP_CONTENT_TYPE", "application/json")]

        app = self._get_mock_app(self._wsgi_environ, expected_response,
                                 expected_headers)

        invoker = FantasticoUrlInternalInvoker(app, self._wsgi_environ)

        response = invoker.invoke_url(url, headers)

        self.assertEqual(expected_response, response)
        self.assertEqual(200, invoker.http_status)
        self.assertEqual(expected_headers, invoker.http_headers)

        return invoker