aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/szurubooru/tests/api/test_tag_category_creating.py7
-rw-r--r--server/szurubooru/tests/conftest.py3
-rw-r--r--server/szurubooru/tests/func/test_tag_categories.py14
3 files changed, 17 insertions, 7 deletions
diff --git a/server/szurubooru/tests/api/test_tag_category_creating.py b/server/szurubooru/tests/api/test_tag_category_creating.py
index 2370cb8..6798cbe 100644
--- a/server/szurubooru/tests/api/test_tag_category_creating.py
+++ b/server/szurubooru/tests/api/test_tag_category_creating.py
@@ -36,11 +36,14 @@ def test_creating_category(
tag_categories.serialize_category.return_value = "serialized category"
result = api.tag_category_api.create_tag_category(
context_factory(
- params={"name": "meta", "color": "black"}, user=auth_user
+ params={"name": "meta", "color": "black", "order": 0},
+ user=auth_user,
)
)
assert result == "serialized category"
- tag_categories.create_category.assert_called_once_with("meta", "black")
+ tag_categories.create_category.assert_called_once_with(
+ "meta", "black", 0
+ )
snapshots.create.assert_called_once_with(category, auth_user)
diff --git a/server/szurubooru/tests/conftest.py b/server/szurubooru/tests/conftest.py
index 481d884..e7811fe 100644
--- a/server/szurubooru/tests/conftest.py
+++ b/server/szurubooru/tests/conftest.py
@@ -126,10 +126,11 @@ def user_token_factory(user_factory):
@pytest.fixture
def tag_category_factory():
- def factory(name=None, color="dummy", default=False):
+ def factory(name=None, color="dummy", order=1, default=False):
category = model.TagCategory()
category.name = name or get_unique_name()
category.color = color
+ category.order = order
category.default = default
return category
diff --git a/server/szurubooru/tests/func/test_tag_categories.py b/server/szurubooru/tests/func/test_tag_categories.py
index e369068..11300cf 100644
--- a/server/szurubooru/tests/func/test_tag_categories.py
+++ b/server/szurubooru/tests/func/test_tag_categories.py
@@ -37,8 +37,8 @@ def test_serialize_category(tag_category_factory, tag_factory):
def test_create_category_when_first():
with patch("szurubooru.func.tag_categories.update_category_name"), patch(
"szurubooru.func.tag_categories.update_category_color"
- ):
- category = tag_categories.create_category("name", "color")
+ ), patch("szurubooru.func.tag_categories.update_category_order"):
+ category = tag_categories.create_category("name", "color", 7)
assert category.default
tag_categories.update_category_name.assert_called_once_with(
category, "name"
@@ -46,6 +46,9 @@ def test_create_category_when_first():
tag_categories.update_category_color.assert_called_once_with(
category, "color"
)
+ tag_categories.update_category_order.assert_called_once_with(
+ category, 7
+ )
def test_create_category_when_subsequent(tag_category_factory):
@@ -53,8 +56,8 @@ def test_create_category_when_subsequent(tag_category_factory):
db.session.flush()
with patch("szurubooru.func.tag_categories.update_category_name"), patch(
"szurubooru.func.tag_categories.update_category_color"
- ):
- category = tag_categories.create_category("name", "color")
+ ), patch("szurubooru.func.tag_categories.update_category_order"):
+ category = tag_categories.create_category("name", "color", 7)
assert not category.default
tag_categories.update_category_name.assert_called_once_with(
category, "name"
@@ -62,6 +65,9 @@ def test_create_category_when_subsequent(tag_category_factory):
tag_categories.update_category_color.assert_called_once_with(
category, "color"
)
+ tag_categories.update_category_order.assert_called_once_with(
+ category, 7
+ )
def test_update_category_name_with_empty_string(tag_category_factory):

© 2015 - 2026 Jakob L. Kreuze