Skip to content

Commit

Permalink
Merge branch 'main' into feat/run-tests-without-ffs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleith authored Jul 24, 2024
2 parents 279c6ef + 01ad65d commit 04f3da0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/notify_client/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from functools import wraps
from inspect import signature

from flask import current_app

from app.extensions import redis_client

TTL = int(timedelta(days=7).total_seconds())
Expand Down Expand Up @@ -76,6 +78,11 @@ def set(key_format):
def _set(client_method):
@wraps(client_method)
def new_client_method(client_instance, *args, **kwargs):
if client_method.__qualname__ == "TemplateCategoryClient.get_all_template_categories":
current_app.logger.info(
f"cache.set() -> client_instance: {client_instance.__module__} args: {args} kwargs: {kwargs}"
)

redis_key = _make_key(key_format, client_method, args, kwargs)
cached = redis_client.get(redis_key)
if cached:
Expand Down
3 changes: 2 additions & 1 deletion app/notify_client/template_category_api_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from flask import current_app
from requests import HTTPError

from app.notify_client import NotifyAdminAPIClient, cache
Expand Down Expand Up @@ -27,7 +28,7 @@ def get_template_category(self, template_category_id):
@cache.set("template_categories")
def get_all_template_categories(self, template_type=None, hidden=None, sort_key=None):
categories = self.get(url="/template-category")["template_categories"]

current_app.logger.info(f"get_all_template_categories response: {categories}")
if len(categories) > 0:
if sort_key and sort_key in categories[0]:
categories.sort(key=lambda category: category[sort_key].lower())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_get_template_category(template_category_client, mocker, fake_uuid):
)


def test_get_all_template_categories(template_category_client, mocker, fake_uuid):
def test_get_all_template_categories(app_, template_category_client, mocker, fake_uuid):
mock_get = mocker.patch(
"app.notify_client.template_category_api_client.TemplateCategoryClient.get",
return_value={"template_categories": [1, 2, 3]},
Expand Down

0 comments on commit 04f3da0

Please sign in to comment.