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

extend test_app_with_views check app follows flask 0.6 default behavior

flask default behavio for url_rules methods is, that it defaults to
GET, HEAD and OPTIONS if no methods is set. This musst be reflected by
the manifest.
parent 3c2cb724
Branches
Tags
1 merge request!16Resolve "Unterstützung von anderen HTTP-Methoden als GET innerhalb einer APP"
...@@ -66,7 +66,8 @@ class TestSAMSApp(unittest.TestCase): ...@@ -66,7 +66,8 @@ class TestSAMSApp(unittest.TestCase):
'GET', 'POST', 'DELETE', 'PUT', 'UPDATE', 'HEAD', 'PATCH', 'GET', 'POST', 'DELETE', 'PUT', 'UPDATE', 'HEAD', 'PATCH',
'OPTIONS' 'OPTIONS'
] ]
} },
{'url': 'test/do_nothing_defaults', 'function': 'views.do_nothing'}
] ]
} }
app = SAMSApp(name = 'test', manifest = manifest app = SAMSApp(name = 'test', manifest = manifest
...@@ -79,10 +80,17 @@ class TestSAMSApp(unittest.TestCase): ...@@ -79,10 +80,17 @@ class TestSAMSApp(unittest.TestCase):
thApp.start() thApp.start()
time.sleep(0.01) time.sleep(0.01)
for method in manifest['views'][0]['methods']: for method in manifest['views'][0]['methods']:
with self.subTest(method): with self.subTest('do_nothing: ' + method):
response = requests.request( response = requests.request(
method = method, url = 'http://localhost:5000/test/do_nothing') method = method, url = 'http://localhost:5000/test/do_nothing')
self.assertIs(response.status_code, 200) self.assertIs(response.status_code, 200)
for method in ('GET', 'HEAD', 'OPTIONS'):
# Check that app follows flask 0.6 default behavior for no methods defined
with self.subTest('do_nothing_default: ' + method):
response = requests.request(
method = method,
url = 'http://localhost:5000/test/do_nothing_defaults')
self.assertIs(response.status_code, 200)
requests.request( requests.request(
method = 'GET', url = 'http://localhost:5000/shutdown') method = 'GET', url = 'http://localhost:5000/shutdown')
time.sleep(0.01) time.sleep(0.01)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment