|
|
@ -21,7 +21,6 @@ class BlueprintsTest(TestCase):
|
|
|
|
def setUpClass(cls):
|
|
|
|
def setUpClass(cls):
|
|
|
|
"""Set up only once, and re-use in every individual test"""
|
|
|
|
"""Set up only once, and re-use in every individual test"""
|
|
|
|
cls.app = Flask("test_extensions")
|
|
|
|
cls.app = Flask("test_extensions")
|
|
|
|
cls.app.debug = False
|
|
|
|
|
|
|
|
cls.client = cls.app.test_client()
|
|
|
|
cls.client = cls.app.test_client()
|
|
|
|
cls.senpy = Senpy(default_plugins=True)
|
|
|
|
cls.senpy = Senpy(default_plugins=True)
|
|
|
|
cls.senpy.init_app(cls.app)
|
|
|
|
cls.senpy.init_app(cls.app)
|
|
|
@ -31,6 +30,9 @@ class BlueprintsTest(TestCase):
|
|
|
|
cls.senpy.activate_plugin("DummyRequired", sync=True)
|
|
|
|
cls.senpy.activate_plugin("DummyRequired", sync=True)
|
|
|
|
cls.senpy.default_plugin = 'Dummy'
|
|
|
|
cls.senpy.default_plugin = 'Dummy'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
|
|
|
self.app.config['TESTING'] = True # Tell Flask not to catch Exceptions
|
|
|
|
|
|
|
|
|
|
|
|
def assertCode(self, resp, code):
|
|
|
|
def assertCode(self, resp, code):
|
|
|
|
self.assertEqual(resp.status_code, code)
|
|
|
|
self.assertEqual(resp.status_code, code)
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +44,7 @@ class BlueprintsTest(TestCase):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Calling with no arguments should ask the user for more arguments
|
|
|
|
Calling with no arguments should ask the user for more arguments
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.app.config['TESTING'] = False # Errors are expected in this case
|
|
|
|
resp = self.client.get("/api/")
|
|
|
|
resp = self.client.get("/api/")
|
|
|
|
self.assertCode(resp, 400)
|
|
|
|
self.assertCode(resp, 400)
|
|
|
|
js = parse_resp(resp)
|
|
|
|
js = parse_resp(resp)
|
|
|
@ -81,7 +84,7 @@ class BlueprintsTest(TestCase):
|
|
|
|
Extra params that have a required argument that does not
|
|
|
|
Extra params that have a required argument that does not
|
|
|
|
have a default should raise an error.
|
|
|
|
have a default should raise an error.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.app.debug = False
|
|
|
|
self.app.config['TESTING'] = False # Errors are expected in this case
|
|
|
|
resp = self.client.get("/api/?i=My aloha mohame&algo=DummyRequired")
|
|
|
|
resp = self.client.get("/api/?i=My aloha mohame&algo=DummyRequired")
|
|
|
|
self.assertCode(resp, 400)
|
|
|
|
self.assertCode(resp, 400)
|
|
|
|
js = parse_resp(resp)
|
|
|
|
js = parse_resp(resp)
|
|
|
@ -97,7 +100,7 @@ class BlueprintsTest(TestCase):
|
|
|
|
The dummy plugin returns an empty response,\
|
|
|
|
The dummy plugin returns an empty response,\
|
|
|
|
it should contain the context
|
|
|
|
it should contain the context
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.app.debug = False
|
|
|
|
self.app.config['TESTING'] = False # Errors are expected in this case
|
|
|
|
resp = self.client.get("/api/?i=My aloha mohame&algo=DOESNOTEXIST")
|
|
|
|
resp = self.client.get("/api/?i=My aloha mohame&algo=DOESNOTEXIST")
|
|
|
|
self.assertCode(resp, 404)
|
|
|
|
self.assertCode(resp, 404)
|
|
|
|
js = parse_resp(resp)
|
|
|
|
js = parse_resp(resp)
|
|
|
@ -172,5 +175,6 @@ class BlueprintsTest(TestCase):
|
|
|
|
assert "help" in js["valid_parameters"]
|
|
|
|
assert "help" in js["valid_parameters"]
|
|
|
|
|
|
|
|
|
|
|
|
def test_conversion(self):
|
|
|
|
def test_conversion(self):
|
|
|
|
|
|
|
|
self.app.config['TESTING'] = False # Errors are expected in this case
|
|
|
|
resp = self.client.get("/api/?input=hello&algo=emoRand&emotionModel=DOES NOT EXIST")
|
|
|
|
resp = self.client.get("/api/?input=hello&algo=emoRand&emotionModel=DOES NOT EXIST")
|
|
|
|
self.assertCode(resp, 404)
|
|
|
|
self.assertCode(resp, 404)
|
|
|
|