Skip to content
Snippets Groups Projects

Resolve "Unterstützung von anderen HTTP-Methoden als GET innerhalb einer APP"

Merged slobinger requested to merge 21-support--http-methods-for-app-urls into master
1 file
+ 19
6
Compare changes
  • Side-by-side
  • Inline
+ 19
6
@@ -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)
self.assertGreater(len(list(flaskApp.url_map.iter_rules())), 1)
with self.subTest('test url_map'):
client = flaskApp.test_client(self)
self.assertGreater(len(list(flaskApp.url_map.iter_rules())), 1)
response = client.get('/test/do_nothing')
thApp = FlaskInThread(flaskApp, host="localhost", port=5000)
self.assertIs(response.status_code, 200)
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)
 
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."""
Loading