server/tags: fix getting default category name
No categories? Should have thrown an error rather than returning None.
This commit is contained in:
parent
cce543e0b6
commit
e92bd2fd80
2 changed files with 4 additions and 3 deletions
|
@ -139,8 +139,8 @@ def get_default_category(lock=False):
|
|||
def get_default_category_name():
|
||||
if cache.has(DEFAULT_CATEGORY_NAME_CACHE_KEY):
|
||||
return cache.get(DEFAULT_CATEGORY_NAME_CACHE_KEY)
|
||||
default_category = try_get_default_category()
|
||||
default_category_name = default_category.name if default_category else None
|
||||
default_category = get_default_category()
|
||||
default_category_name = default_category.name
|
||||
cache.put(DEFAULT_CATEGORY_NAME_CACHE_KEY, default_category_name)
|
||||
return default_category_name
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ def test_get_default_category_name(tag_category_factory):
|
|||
assert tag_categories.get_default_category_name() == category1.name
|
||||
db.session.query(db.TagCategory).delete()
|
||||
cache.purge()
|
||||
assert tag_categories.get_default_category_name() is None
|
||||
with pytest.raises(tag_categories.TagCategoryNotFoundError):
|
||||
tag_categories.get_default_category_name()
|
||||
|
||||
|
||||
def test_get_default_category_name_caching(tag_category_factory):
|
||||
|
|
Loading…
Reference in a new issue