1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-25 01:22:28 +00:00
senpy/tests/blueprints_test/__init__.py

39 lines
1018 B
Python
Raw Permalink Normal View History

2014-11-20 18:29:49 +00:00
2014-11-07 18:12:21 +00:00
import os
import logging
2014-11-20 18:29:49 +00:00
2014-11-07 18:12:21 +00:00
try:
import unittest.mock as mock
except ImportError:
import mock
from senpy.extensions import Senpy
from flask import Flask
from flask.ext.testing import TestCase
2014-11-20 18:29:49 +00:00
2014-11-07 18:12:21 +00:00
def check_dict(indic, template):
2014-11-20 18:29:49 +00:00
return all(item in indic.items() for item in template.items())
2014-11-07 18:12:21 +00:00
2014-11-20 18:29:49 +00:00
class BlueprintsTest(TestCase):
2014-11-07 18:12:21 +00:00
def create_app(self):
self.app = Flask("test_extensions")
self.senpy = Senpy()
self.senpy.init_app(self.app)
self.dir = os.path.join(os.path.dirname(__file__), "..")
self.senpy.add_folder(self.dir)
return self.app
def test_home(self):
""" Calling with no arguments should ask the user for more arguments """
resp = self.client.get("/")
self.assert200(resp)
logging.debug(resp.json)
assert resp.json["status"] == "failed"
atleast = {
"status": "failed",
"message": "Missing or invalid parameters",
}
assert check_dict(resp.json, atleast)