Skip to content
Snippets Groups Projects
Commit 8a62408a authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

extend test_app_with_view in test_sams_app.py to reflect issue #21

parent 6d53c50e
No related branches found
No related tags found
1 merge request!16Resolve "Unterstützung von anderen HTTP-Methoden als GET innerhalb einer APP"
...@@ -60,18 +60,31 @@ class TestSAMSApp(unittest.TestCase): ...@@ -60,18 +60,31 @@ class TestSAMSApp(unittest.TestCase):
manifest = { manifest = {
'default_language': 'en' 'default_language': 'en'
, 'views': [ , 'views': [
{'url': 'test/do_nothing' {'url': 'test/do_nothing',
, 'function': 'views.do_nothing'} 'function': 'views.do_nothing',
'methods': [
'GET', 'POST', 'DELETE', 'PUT', 'UPDATE', 'HEADER', 'PATCH'
]
}
] ]
} }
app = SAMSApp(name = 'test', manifest = manifest app = SAMSApp(name = 'test', manifest = manifest
, langDict = {'en':{}}) , langDict = {'en':{}})
flaskApp = Flask(__name__) flaskApp = Flask(__name__)
flaskApp.register_blueprint(app.blueprint) flaskApp.register_blueprint(app.blueprint)
with self.subTest('test url_map'):
self.assertGreater(len(list(flaskApp.url_map.iter_rules())), 1) self.assertGreater(len(list(flaskApp.url_map.iter_rules())), 1)
client = flaskApp.test_client(self) thApp = FlaskInThread(flaskApp, host="localhost", port=5000)
response = client.get('/test/do_nothing') thApp.start()
time.sleep(0.01)
for method in manifest['views'][0]['methods']:
with self.subTest(method):
response = requests.request(
method = method, url = 'http://localhost:5000/test/do_nothing')
self.assertIs(response.status_code, 200) self.assertIs(response.status_code, 200)
requests.request(
method = 'GET', url = 'http://localhost:5000/shutdown')
time.sleep(0.01)
def test_app_lang(self): def test_app_lang(self):
"""App.lang(language) returns dict with requested language / default.""" """App.lang(language) returns dict with requested language / default."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment