mirror of
https://github.com/gsi-upm/senpy
synced 2025-08-24 02:22:20 +00:00
PEP8+Better JSON-LD support
* The API has also changed, there are new parameters to send the context as part of the headers. * Improved tests * PEP8 compliance (despite the line about gevent)
This commit is contained in:
@@ -11,6 +11,7 @@ from flask.ext.testing import TestCase
|
||||
|
||||
|
||||
class ExtensionsTest(TestCase):
|
||||
|
||||
def create_app(self):
|
||||
self.app = Flask("test_extensions")
|
||||
self.dir = os.path.join(os.path.dirname(__file__), "..")
|
||||
@@ -42,19 +43,30 @@ class ExtensionsTest(TestCase):
|
||||
def test_disabling(self):
|
||||
""" Disabling a plugin """
|
||||
self.senpy.deactivate_all(sync=True)
|
||||
assert self.senpy.plugins["Dummy"].is_activated == False
|
||||
assert self.senpy.plugins["Sleep"].is_activated == False
|
||||
assert not self.senpy.plugins["Dummy"].is_activated
|
||||
assert not self.senpy.plugins["Sleep"].is_activated
|
||||
|
||||
def test_default(self):
|
||||
""" Default plugin should be set """
|
||||
assert self.senpy.default_plugin
|
||||
assert self.senpy.default_plugin == "Dummy"
|
||||
assert self.senpy.default_plugin.name == "Dummy"
|
||||
self.senpy.deactivate_all(sync=True)
|
||||
logging.debug("Default: {}".format(self.senpy.default_plugin))
|
||||
assert self.senpy.default_plugin is None
|
||||
|
||||
def test_noplugin(self):
|
||||
""" Don't analyse if there isn't any plugin installed """
|
||||
self.senpy.deactivate_all(sync=True)
|
||||
resp = self.senpy.analyse(input="tupni")
|
||||
logging.debug("Response: {}".format(resp))
|
||||
assert resp["status"] == 404
|
||||
|
||||
def test_analyse(self):
|
||||
""" Using a plugin """
|
||||
# I was using mock until plugin started inheriting Leaf (defaultdict with
|
||||
# __setattr__ and __getattr__.
|
||||
r1 = self.senpy.analyse(algorithm="Dummy", input="tupni", output="tuptuo")
|
||||
# I was using mock until plugin started inheriting
|
||||
# Leaf (defaultdict with __setattr__ and __getattr__.
|
||||
r1 = self.senpy.analyse(
|
||||
algorithm="Dummy", input="tupni", output="tuptuo")
|
||||
r2 = self.senpy.analyse(input="tupni", output="tuptuo")
|
||||
assert r1.analysis[0].id[:5] == "Dummy"
|
||||
assert r2.analysis[0].id[:5] == "Dummy"
|
||||
@@ -62,7 +74,7 @@ class ExtensionsTest(TestCase):
|
||||
self.senpy.deactivate_plugin(plug, sync=True)
|
||||
resp = self.senpy.analyse(input="tupni")
|
||||
logging.debug("Response: {}".format(resp))
|
||||
assert resp["status"] == 400
|
||||
assert resp["status"] == 404
|
||||
|
||||
def test_filtering(self):
|
||||
""" Filtering plugins """
|
||||
@@ -70,4 +82,5 @@ class ExtensionsTest(TestCase):
|
||||
assert not len(self.senpy.filter_plugins(name="notdummy"))
|
||||
assert self.senpy.filter_plugins(name="Dummy", is_activated=True)
|
||||
self.senpy.deactivate_plugin("Dummy", sync=True)
|
||||
assert not len(self.senpy.filter_plugins(name="Dummy", is_activated=True))
|
||||
assert not len(
|
||||
self.senpy.filter_plugins(name="Dummy", is_activated=True))
|
||||
|
Reference in New Issue
Block a user