From 5d9da36bc51416e8b23e411985ab1ae448e87ab1 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Mon, 28 Oct 2024 17:27:34 +0200 Subject: [PATCH] add workaround for postman flow Add endpoint specifically designed to make sure postman flow will execute correctly on any run regardless of what previous changes have been done to the server database. --- app/__init__.py | 5 +++++ app/local_db.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index 9f34e3f..ce226be 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,6 +12,11 @@ def ep_healthcheck(): "status": "OK" } +@app.route("/reset_users_because_postman_is_dumb_like_that") +def ep_reset(): + ldb.reset() + return {} + @app.route("/users", methods = ["GET"]) def ep_users_get(): return ldb.get_users() diff --git a/app/local_db.py b/app/local_db.py index 02b6206..ddb0b9b 100644 --- a/app/local_db.py +++ b/app/local_db.py @@ -6,6 +6,11 @@ class LocalDB: self.categories = {} self.records = {} + def reset(self): + for k, v in list(self.users.items()): + if v == "test1": + del self.users[k] + def get_users(self): return self.users