Пример #1
0
    def test_404(self):
        """No URL rules defined."""
        app = Tipfy()
        client = app.get_test_client()

        # Normal mode.
        response = client.get('/')
        self.assertEqual(response.status_code, 404)

        # Debug mode.
        app.debug = True
        response = client.get('/')
        self.assertEqual(response.status_code, 404)
Пример #2
0
    def test_501(self):
        """Method is not in app.allowed_methods."""
        app = Tipfy()
        client = app.get_test_client()

        # Normal mode.
        response = client.open('/', method='CONNECT')
        self.assertEqual(response.status_code, 501)

        # Debug mode.
        app.debug = True
        response = client.open('/', method='CONNECT')
        self.assertEqual(response.status_code, 501)
Пример #3
0
    def test_500(self):
        """Handler import will fail."""
        app = Tipfy(rules=[Rule('/', name='home', handler='non.existent.handler')])
        client = app.get_test_client()

        # Normal mode.
        response = client.get('/')
        self.assertEqual(response.status_code, 500)

        # Debug mode.
        app.debug = True
        app.config['tipfy']['enable_debugger'] = False
        self.assertRaises(ImportError, client.get, '/')
Пример #4
0
    def test_404(self):
        """No URL rules defined."""
        app = Tipfy()
        client = app.get_test_client()

        # Normal mode.
        response = client.get('/')
        self.assertEqual(response.status_code, 404)

        # Debug mode.
        app.debug = True
        response = client.get('/')
        self.assertEqual(response.status_code, 404)
Пример #5
0
    def test_501(self):
        """Method is not in app.allowed_methods."""
        app = Tipfy()
        client = app.get_test_client()

        # Normal mode.
        response = client.open('/', method='CONNECT')
        self.assertEqual(response.status_code, 501)

        # Debug mode.
        app.debug = True
        response = client.open('/', method='CONNECT')
        self.assertEqual(response.status_code, 501)
Пример #6
0
    def test_500(self):
        """Handler import will fail."""
        app = Tipfy(
            rules=[Rule('/', name='home', handler='non.existent.handler')])
        client = app.get_test_client()

        # Normal mode.
        response = client.get('/')
        self.assertEqual(response.status_code, 500)

        # Debug mode.
        app.debug = True
        app.config['tipfy']['enable_debugger'] = False
        self.assertRaises(ImportError, client.get, '/')