diff --git a/server/szurubooru/func/tag_categories.py b/server/szurubooru/func/tag_categories.py index bec2f0d..b6e0257 100644 --- a/server/szurubooru/func/tag_categories.py +++ b/server/szurubooru/func/tag_categories.py @@ -131,11 +131,12 @@ def get_category_by_name(name: str, lock: bool = False) -> model.TagCategory: def get_all_category_names() -> List[str]: - return [row[0] for row in db.session.query(model.TagCategory.name).all()] + return [cat.name for cat in get_all_categories()] def get_all_categories() -> List[model.TagCategory]: - return db.session.query(model.TagCategory).all() + return db.session.query(model.TagCategory).order_by( + model.TagCategory.name.asc()).all() def try_get_default_category( diff --git a/server/szurubooru/tests/api/test_tag_retrieving.py b/server/szurubooru/tests/api/test_tag_retrieving.py index 43a0766..c720b6e 100644 --- a/server/szurubooru/tests/api/test_tag_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_retrieving.py @@ -17,7 +17,7 @@ def inject_config(config_injector): def test_retrieving_multiple(user_factory, tag_factory, context_factory): tag1 = tag_factory(names=['t1']) tag2 = tag_factory(names=['t2']) - db.session.add_all([tag1, tag2]) + db.session.add_all([tag2, tag1]) db.session.flush() with patch('szurubooru.func.tags.serialize_tag'): tags.serialize_tag.return_value = 'serialized tag' diff --git a/server/szurubooru/tests/func/test_tag_categories.py b/server/szurubooru/tests/func/test_tag_categories.py index d1e5570..d886703 100644 --- a/server/szurubooru/tests/func/test_tag_categories.py +++ b/server/szurubooru/tests/func/test_tag_categories.py @@ -148,7 +148,7 @@ def test_get_category_by_name(tag_category_factory): def test_get_all_category_names(tag_category_factory): category1 = tag_category_factory(name='cat1') category2 = tag_category_factory(name='cat2') - db.session.add_all([category1, category2]) + db.session.add_all([category2, category1]) db.session.flush() assert tag_categories.get_all_category_names() == ['cat1', 'cat2'] @@ -156,7 +156,7 @@ def test_get_all_category_names(tag_category_factory): def test_get_all_categories(tag_category_factory): category1 = tag_category_factory(name='cat1') category2 = tag_category_factory(name='cat2') - db.session.add_all([category1, category2]) + db.session.add_all([category2, category1]) db.session.flush() assert tag_categories.get_all_categories() == [category1, category2]