server/tests: fix failing tests
This commit is contained in:
parent
b5d2e447fc
commit
d4f72de8c2
3 changed files with 17 additions and 7 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue