Ejemplo n.º 1
0
    def test_10_publish(self):
        """Test direct exception publishing.
        """
        self.app = self.create_application()

        try:
            raise ValueError
        except ValueError:
            type, exception, traceback = exc_info()
            traceback = Traceback(type, exception, traceback)

        with self.app.test_request_context():
            Exceptional.publish(self.app.config, traceback)
            data = json.loads(g.exceptional)
            exception = data["exception"]
            assert exception["exception_class"] == ValueError.__name__
Ejemplo n.º 2
0
    def test_07_unexceptional(self):
        """Test disabled Exceptional logging.
        """
        self.app = self.create_application()
        del self.app.config["EXCEPTIONAL_API_KEY"]
        Exceptional(self.app)

        with self.app.test_client() as client:
            client.get("/error")
            assert hasattr(g, "exceptional") is False
Ejemplo n.º 3
0
    def test_11_utf8_decode(self):
        """Test sending an invalid UTF-8 byte sequence through Exceptional.
        """
        self.app.config["INVALID_UTF-8"] = "\xf0"
        Exceptional(self.app)

        with self.app.test_client() as client:
            client.get("/error")
            data = json.loads(g.exceptional)
            application_environment = data["application_environment"]
            environment = application_environment["env"]
            assert environment["INVALID_UTF-8"] == u"\ufffd"
Ejemplo n.º 4
0
    def test_05_filter_header(self):
        """Test header data filtering.
        """
        self.app.config["EXCEPTIONAL_HEADER_FILTER"] = ["Host"]
        Exceptional(self.app)

        with self.app.test_client() as client:
            client.get("/error")
            data = json.loads(g.exceptional)
            request = data["request"]
            headers = request["headers"]
            assert headers["Host"] == "[FILTERED]"
Ejemplo n.º 5
0
    def test_12_json(self):
        """Test JSON request handling.
        """
        self.app = self.create_application()
        Exceptional(self.app)
        data = json.dumps({"foo": {"bar": "baz"}})

        with self.app.test_client() as client:
            client.post("/error", content_type="application/json", data=data)
            data = json.loads(g.exceptional)
            request = data["request"]
            parameters = request["parameters"]
            assert "bar" in parameters["foo"]
Ejemplo n.º 6
0
    def test_06_filter_parameter(self):
        """Test parameter data filtering.
        """
        data = {"foo": "bar", "baz": "qux"}
        self.app.config["EXCEPTIONAL_PARAMETER_FILTER"] = ["baz"]
        Exceptional(self.app)

        with self.app.test_client() as client:
            client.post("/error", data=data)
            data = json.loads(g.exceptional)
            request = data["request"]
            parameters = request["parameters"]
            assert parameters["baz"] == "[FILTERED]"
Ejemplo n.º 7
0
    def test_10_publish(self):
        """Test direct exception publishing.
        """
        self.app = self.create_application()

        try:
            raise ValueError
        except ValueError:
            type, exception, traceback = exc_info()
            traceback = Traceback(type, exception, traceback)

        data = json.loads(Exceptional.publish(self.app.config, traceback))
        exception = data["exception"]
        assert exception["exception_class"] == ValueError.__name__
Ejemplo n.º 8
0
    def test_09_debug(self):
        """Test exception in debug mode.
        """
        self.app = self.create_application()
        self.app.debug = True
        exceptional = Exceptional(self.app)
        self.app.config["EXCEPTIONAL_ENVIRONMENT_FILTER"].append("os.*")
        self.app.config["PROPAGATE_EXCEPTIONS"] = None
        assert exceptional.url == self.app.config["EXCEPTIONAL_DEBUG_URL"]

        with self.app.test_client() as client:
            self.assertRaises(ZeroDivisionError, client.get, "/error")
            json.loads(g.exceptional)
            print "See %s for HTTP request details." % exceptional.url
Ejemplo n.º 9
0
            def ret_val(exception):
                Exceptional.context(foo="bar")

                return handle_exception(exception)
Ejemplo n.º 10
0
 def setUp(self):
     """Set up each test.
     """
     self.app = self.create_application()
     self.exceptional = Exceptional(self.app)
Ejemplo n.º 11
0
            def ret_val(exception):
                Exceptional.context(foo="bar")

                return handle_exception(exception)