From d4f72de8c24e03e4f2420772af373ee7952e35c7 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Thu, 24 Sep 2020 12:57:26 -0400 Subject: [PATCH] server/tests: fix failing tests --- .../tests/api/test_tag_category_creating.py | 7 +++++-- server/szurubooru/tests/conftest.py | 3 ++- .../szurubooru/tests/func/test_tag_categories.py | 14 ++++++++++---- 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 2370cb83..6798cbe2 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 481d884a..e7811fe1 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 e369068c..11300cf4 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):