Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/opengeodeweb_back/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ def update_last_request_time(current_app):
current_app.config.update(LAST_REQUEST_TIME=LAST_REQUEST_TIME)


def before_request(current_app):
increment_request_counter(current_app)


def teardown_request(current_app):
decrement_request_counter(current_app)
update_last_request_time(current_app)


def kill_task(current_app):
DESKTOP_APP = bool(current_app.config.get("DESKTOP_APP"))
REQUEST_COUNTER = int(current_app.config.get("REQUEST_COUNTER"))
Expand Down
14 changes: 14 additions & 0 deletions tests/test_utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ def test_update_last_request_time(app_context):
assert flask.current_app.config.get("LAST_REQUEST_TIME") >= LAST_REQUEST_TIME


def test_before_request(app_context):
assert flask.current_app.config.get("REQUEST_COUNTER") == 0
utils_functions.before_request(flask.current_app)
assert flask.current_app.config.get("REQUEST_COUNTER") == 1


def test_teardown_request(app_context):
LAST_REQUEST_TIME = flask.current_app.config.get("LAST_REQUEST_TIME")
assert flask.current_app.config.get("REQUEST_COUNTER") == 1
utils_functions.teardown_request(flask.current_app)
assert flask.current_app.config.get("REQUEST_COUNTER") == 0
assert flask.current_app.config.get("LAST_REQUEST_TIME") >= LAST_REQUEST_TIME


def test_versions():
list_packages = [
"OpenGeode-core",
Expand Down