aboutsummaryrefslogtreecommitdiffstats
path: root/app_test.py
diff options
context:
space:
mode:
authorGravatar Joseph <[email protected]>2018-02-28 23:33:35 +0000
committerGravatar GitHub <[email protected]>2018-02-28 23:33:35 +0000
commitc2dfc1bb34e8153bc7372ce6056c6883616ece9b (patch)
tree0df39f5f8d60d3f528d48347e9a5c8b276875175 /app_test.py
parentreduce memory allocation from 2GB to 512MB (#28) (diff)
Add error messages (#30)
* Add error messages Signed-off-by: JoeBanks13 <[email protected]> * Remove un-used keyword arg from 404 * Assert for status code instead of full content * PEP8 * test lint * please coverage * oh * Exclude websockets.py from coverage * Move code output into terminal * Switch typewriter href protocol * Add tests for websockets.py * Abort previous commit, coveralls did not let coverage go down * Add more pauses and request => response * move css and js out, add typewriter JS to our own repo & add method for appending text in bulk. * Enable REPL on 4XX and change error descriptions * commas * /error path
Diffstat (limited to 'app_test.py')
-rw-r--r--app_test.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/app_test.py b/app_test.py
index 35b36af4..2e8a53fb 100644
--- a/app_test.py
+++ b/app_test.py
@@ -1,12 +1,11 @@
import json
import os
-from app import manager
-
from flask import Blueprint
-
from flask_testing import TestCase
+from app import manager
+
manager.app.tests_blueprint = Blueprint("tests", __name__)
manager.load_views(manager.app.tests_blueprint, "pysite/views/tests")
manager.app.register_blueprint(manager.app.tests_blueprint)
@@ -44,6 +43,11 @@ class BaseEndpoints(SiteTest):
response = self.client.get('/nonexistentpath')
self.assertEqual(response.status_code, 404)
+ def test_error(self):
+ """ Check the /error/XYZ page """
+ response = self.client.get('/error/418')
+ self.assertEqual(response.status_code, 418)
+
def test_invite(self):
""" Check invite redirects """
response = self.client.get('/invite')
@@ -59,6 +63,11 @@ class BaseEndpoints(SiteTest):
response = self.client.get('/datadog')
self.assertEqual(response.status_code, 302)
+ def test_500_easter_egg(self):
+ """Check the status of the /500 page"""
+ response = self.client.get("/500")
+ self.assertEqual(response.status_code, 500)
+
class ApiEndpoints(SiteTest):
""" test cases for the api subdomain """
@@ -172,6 +181,20 @@ class Utilities(SiteTest):
return True
raise Exception('Expected runtime error on setup() when giving wrongful arguments')
+ def test_websocket_callback(self):
+ """ Check that websocket default callbacks work """
+ import pysite.websockets
+
+ class TestWS(pysite.websockets.WS):
+ pass
+
+ try:
+ TestWS(None).on_message("test")
+ return False
+ except NotImplementedError:
+ return True
+
+
class MixinTests(SiteTest):
""" Test cases for mixins """
@@ -202,9 +225,9 @@ class MixinTests(SiteTest):
from werkzeug.exceptions import InternalServerError
from pysite.views.error_handlers import http_5xx
- error_view = http_5xx.Error404View()
+ error_view = http_5xx.Error500View()
error_message = error_view.get(InternalServerError)
- self.assertEqual(error_message, ('Internal server error. Please try again later!', 500))
+ self.assertEqual(error_message[1], 500)
def test_route_view_runtime_error(self):
""" Check that wrong values for route view setup raises runtime error """