Ejemplo n.º 1
0
    def test_get_stats_key_with_args(self):
        """
        get_stats_key() with path arguments
        """
        self.request.path   = '/test/banana/apple'
        expected            = 'test'

        handler             = RequestHandler(self.app, self.request)
        handler.path_args   = ['banana', 'apple']
        handler.path_kwargs = {}

        key = handler.get_stats_key()

        assert_equal(key, expected)
Ejemplo n.º 2
0
    def test_get_stats_key_no_args(self):
        """
        get_stats_key() with no path arguments
        """
        self.request.path   = '/test'
        expected            = 'test'

        handler             = RequestHandler(self.app, self.request)
        handler.path_args   = []
        handler.path_kwargs = {}

        key = handler.get_stats_key()

        assert_equal(key, expected)
Ejemplo n.º 3
0
    def test_get_stats_key_complex_path(self):
        """
        get_stats_key() with a multi-level path
        """
        self.request.path   = '/test/banana/apple'
        expected            = 'test.banana.apple'

        handler             = RequestHandler(self.app, self.request)
        handler.path_args   = []
        handler.path_kwargs = {}

        key = handler.get_stats_key()

        assert_equal(key, expected)
Ejemplo n.º 4
0
    def test_get_stats_key_http_error(self):
        """
        get_stats_key() with an HTTP error
        """
        self.request.path   = '/test/banana/apple'
        expected            = 'test'
        mock_status         = MagicMock(return_value = 404)

        handler             = RequestHandler(self.app, self.request)
        handler.path_args   = []
        handler.path_kwargs = {}
        handler.get_status  = mock_status

        key = handler.get_stats_key()

        mock_status.assert_called_once_with()
        assert_equal(key, expected)