File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ def update_last_request_time(current_app):
3232 LAST_REQUEST_TIME = time .time ()
3333 current_app .config .update (LAST_REQUEST_TIME = LAST_REQUEST_TIME )
3434
35+ def before_request (current_app ):
36+ increment_request_counter (current_app )
37+
38+ def teardown_request (current_app ):
39+ decrement_request_counter (current_app )
40+ update_last_request_time (current_app )
3541
3642def kill_task (current_app ):
3743 DESKTOP_APP = bool (current_app .config .get ("DESKTOP_APP" ))
Original file line number Diff line number Diff line change @@ -20,6 +20,21 @@ def test_update_last_request_time(app_context):
2020 assert flask .current_app .config .get ("LAST_REQUEST_TIME" ) >= LAST_REQUEST_TIME
2121
2222
23+ def test_before_request (app_context ):
24+ assert flask .current_app .config .get ("REQUEST_COUNTER" ) == 0
25+ utils_functions .before_request (flask .current_app )
26+ assert flask .current_app .config .get ("REQUEST_COUNTER" ) == 1
27+
28+
29+ def test_teardown_request (app_context ):
30+ LAST_REQUEST_TIME = flask .current_app .config .get ("LAST_REQUEST_TIME" )
31+ assert flask .current_app .config .get ("REQUEST_COUNTER" ) == 1
32+ utils_functions .teardown_request (flask .current_app )
33+ assert flask .current_app .config .get ("REQUEST_COUNTER" ) == 0
34+ assert flask .current_app .config .get ("LAST_REQUEST_TIME" ) >= LAST_REQUEST_TIME
35+
36+
37+
2338def test_versions ():
2439 list_packages = [
2540 "OpenGeode-core" ,
You can’t perform that action at this time.
0 commit comments