aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/szurubooru/api/tag_api.py4
-rw-r--r--server/szurubooru/func/tags.py23
-rw-r--r--server/szurubooru/tests/api/test_tag_creating.py35
-rw-r--r--server/szurubooru/tests/api/test_tag_merging.py41
-rw-r--r--server/szurubooru/tests/api/test_tag_retrieving.py13
-rw-r--r--server/szurubooru/tests/api/test_tag_updating.py37
-rw-r--r--server/szurubooru/tests/conftest.py9
-rw-r--r--server/szurubooru/tests/func/test_posts.py1
-rw-r--r--server/szurubooru/tests/func/test_snapshots.py22
9 files changed, 97 insertions, 88 deletions
diff --git a/server/szurubooru/api/tag_api.py b/server/szurubooru/api/tag_api.py
index 4e9ec14..2c8a2e2 100644
--- a/server/szurubooru/api/tag_api.py
+++ b/server/szurubooru/api/tag_api.py
@@ -32,7 +32,7 @@ class TagListApi(BaseApi):
auth.verify_privilege(ctx.user, 'tags:create')
names = ctx.get_param_as_list('names', required=True)
- category = ctx.get_param_as_string('category', required=True)
+ category = ctx.get_param_as_string('category', required=True) or ''
description = ctx.get_param_as_string(
'description', required=False, default=None)
suggestions = ctx.get_param_as_list(
@@ -67,7 +67,7 @@ class TagDetailApi(BaseApi):
if ctx.has_param('category'):
auth.verify_privilege(ctx.user, 'tags:edit:category')
tags.update_tag_category_name(
- tag, ctx.get_param_as_string('category'))
+ tag, ctx.get_param_as_string('category') or '')
if ctx.has_param('description'):
auth.verify_privilege(ctx.user, 'tags:edit:description')
tags.update_tag_description(
diff --git a/server/szurubooru/func/tags.py b/server/szurubooru/func/tags.py
index 4456ad1..a061256 100644
--- a/server/szurubooru/func/tags.py
+++ b/server/szurubooru/func/tags.py
@@ -11,9 +11,7 @@ class TagAlreadyExistsError(errors.ValidationError): pass
class TagIsInUseError(errors.ValidationError): pass
class InvalidTagNameError(errors.ValidationError): pass
class InvalidTagRelationError(errors.ValidationError): pass
-
-DEFAULT_CATEGORY_NAME = 'Default'
-DEFAULT_CATEGORY_COLOR = 'default'
+class InvalidTagCategoryError(errors.ValidationError): pass
def _verify_name_validity(name):
name_regex = config.config['tag_name_regex']
@@ -29,13 +27,6 @@ def _lower_list(names):
def _check_name_intersection(names1, names2):
return len(set(_lower_list(names1)).intersection(_lower_list(names2))) > 0
-def _get_default_category_name():
- tag_category = tag_categories.try_get_default_category()
- if tag_category:
- return tag_category.name
- else:
- return DEFAULT_CATEGORY_NAME
-
def sort_tags(tags):
default_category = tag_categories.try_get_default_category()
default_category_name = default_category.name if default_category else None
@@ -146,7 +137,7 @@ def get_or_create_tags_by_names(names):
_verify_name_validity(name)
existing_tags = get_tags_by_names(names)
new_tags = []
- tag_category_name = _get_default_category_name()
+ tag_category_name = tag_categories.get_default_category().name
for name in names:
found = False
for existing_tag in existing_tags:
@@ -213,15 +204,7 @@ def create_tag(names, category_name, suggestions, implications):
return tag
def update_tag_category_name(tag, category_name):
- category = db.session \
- .query(db.TagCategory) \
- .filter(db.TagCategory.name == category_name) \
- .first()
- if not category:
- category = tag_categories.create_category(
- category_name, DEFAULT_CATEGORY_COLOR)
- db.session.add(category)
- tag.category = category
+ tag.category = tag_categories.get_category_by_name(category_name)
def update_tag_names(tag, names):
names = util.icase_unique([name for name in names if name])
diff --git a/server/szurubooru/tests/api/test_tag_creating.py b/server/szurubooru/tests/api/test_tag_creating.py
index 817fe56..6c48ab2 100644
--- a/server/szurubooru/tests/api/test_tag_creating.py
+++ b/server/szurubooru/tests/api/test_tag_creating.py
@@ -2,7 +2,7 @@ import datetime
import os
import pytest
from szurubooru import api, config, db, errors
-from szurubooru.func import util, tags, tag_categories
+from szurubooru.func import util, tags, tag_categories, cache
def assert_relations(relations, expected_tag_names):
actual_names = sorted([rel.names[0].name for rel in relations])
@@ -20,6 +20,7 @@ def test_ctx(
db.session.add_all([
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
db.session.flush()
+ cache.purge()
ret = util.dotdict()
ret.context_factory = context_factory
ret.user_factory = user_factory
@@ -68,9 +69,9 @@ def test_creating_simple_tags(test_ctx, fake_datetime):
({'names': ['']}, tags.InvalidTagNameError),
({'names': ['!bad']}, tags.InvalidTagNameError),
({'names': ['x' * 65]}, tags.InvalidTagNameError),
- ({'category': None}, tag_categories.InvalidTagCategoryNameError),
- ({'category': ''}, tag_categories.InvalidTagCategoryNameError),
- ({'category': '!bad'}, tag_categories.InvalidTagCategoryNameError),
+ ({'category': None}, tag_categories.TagCategoryNotFoundError),
+ ({'category': ''}, tag_categories.TagCategoryNotFoundError),
+ ({'category': '!bad'}, tag_categories.TagCategoryNotFoundError),
({'suggestions': ['good', '!bad']}, tags.InvalidTagNameError),
({'implications': ['good', '!bad']}, tags.InvalidTagNameError),
])
@@ -136,8 +137,8 @@ def test_duplicating_names(test_ctx):
def test_trying_to_use_existing_name(test_ctx):
db.session.add_all([
- test_ctx.tag_factory(names=['used1'], category_name='meta'),
- test_ctx.tag_factory(names=['used2'], category_name='meta'),
+ test_ctx.tag_factory(names=['used1']),
+ test_ctx.tag_factory(names=['used2']),
])
db.session.commit()
with pytest.raises(tags.TagAlreadyExistsError):
@@ -163,15 +164,15 @@ def test_trying_to_use_existing_name(test_ctx):
assert tags.try_get_tag_by_name('unused') is None
def test_creating_new_category(test_ctx):
- test_ctx.api.post(
- test_ctx.context_factory(
- input={
- 'names': ['main'],
- 'category': 'new',
- 'suggestions': [],
- 'implications': [],
- }, user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert tag_categories.try_get_category_by_name('new') is not None
+ with pytest.raises(tag_categories.TagCategoryNotFoundError):
+ test_ctx.api.post(
+ test_ctx.context_factory(
+ input={
+ 'names': ['main'],
+ 'category': 'new',
+ 'suggestions': [],
+ 'implications': [],
+ }, user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
@pytest.mark.parametrize('input,expected_suggestions,expected_implications', [
# new relations
@@ -218,8 +219,8 @@ def test_creating_new_suggestions_and_implications(
def test_reusing_suggestions_and_implications(test_ctx):
db.session.add_all([
- test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta'),
- test_ctx.tag_factory(names=['tag3'], category_name='meta'),
+ test_ctx.tag_factory(names=['tag1', 'tag2']),
+ test_ctx.tag_factory(names=['tag3']),
])
db.session.commit()
result = test_ctx.api.post(
diff --git a/server/szurubooru/tests/api/test_tag_merging.py b/server/szurubooru/tests/api/test_tag_merging.py
index 6be9ab8..3f82021 100644
--- a/server/szurubooru/tests/api/test_tag_merging.py
+++ b/server/szurubooru/tests/api/test_tag_merging.py
@@ -6,7 +6,12 @@ from szurubooru.func import util, tags
@pytest.fixture
def test_ctx(
- tmpdir, config_injector, context_factory, user_factory, tag_factory):
+ tmpdir,
+ config_injector,
+ context_factory,
+ user_factory,
+ tag_factory,
+ tag_category_factory):
config_injector({
'data_dir': str(tmpdir),
'privileges': {
@@ -17,12 +22,14 @@ def test_ctx(
ret.context_factory = context_factory
ret.user_factory = user_factory
ret.tag_factory = tag_factory
+ ret.tag_category_factory = tag_category_factory
ret.api = api.TagMergeApi()
return ret
def test_merging_without_usages(test_ctx, fake_datetime):
- source_tag = test_ctx.tag_factory(names=['source'], category_name='meta')
- target_tag = test_ctx.tag_factory(names=['target'], category_name='meta')
+ category = test_ctx.tag_category_factory(name='meta')
+ source_tag = test_ctx.tag_factory(names=['source'])
+ target_tag = test_ctx.tag_factory(names=['target'], category=category)
db.session.add_all([source_tag, target_tag])
db.session.commit()
with fake_datetime('1997-12-01'):
@@ -54,8 +61,8 @@ def test_merging_without_usages(test_ctx, fake_datetime):
assert os.path.exists(os.path.join(config.config['data_dir'], 'tags.json'))
def test_merging_with_usages(test_ctx, fake_datetime, post_factory):
- source_tag = test_ctx.tag_factory(names=['source'], category_name='meta')
- target_tag = test_ctx.tag_factory(names=['target'], category_name='meta')
+ source_tag = test_ctx.tag_factory(names=['source'])
+ target_tag = test_ctx.tag_factory(names=['target'])
db.session.add_all([source_tag, target_tag])
db.session.flush()
assert source_tag.post_count == 0
@@ -80,8 +87,8 @@ def test_merging_with_usages(test_ctx, fake_datetime, post_factory):
assert tags.get_tag_by_name('target').post_count == 1
def test_merging_when_related(test_ctx, fake_datetime):
- source_tag = test_ctx.tag_factory(names=['source'], category_name='meta')
- target_tag = test_ctx.tag_factory(names=['target'], category_name='meta')
+ source_tag = test_ctx.tag_factory(names=['source'])
+ target_tag = test_ctx.tag_factory(names=['target'])
db.session.add_all([source_tag, target_tag])
db.session.flush()
referring_tag = test_ctx.tag_factory(names=['parent'])
@@ -106,8 +113,8 @@ def test_merging_when_related(test_ctx, fake_datetime):
assert tags.try_get_tag_by_name('parent').suggestions == []
def test_merging_when_target_exists(test_ctx, fake_datetime, post_factory):
- source_tag = test_ctx.tag_factory(names=['source'], category_name='meta')
- target_tag = test_ctx.tag_factory(names=['target'], category_name='meta')
+ source_tag = test_ctx.tag_factory(names=['source'])
+ target_tag = test_ctx.tag_factory(names=['target'])
db.session.add_all([source_tag, target_tag])
db.session.flush()
post1 = post_factory()
@@ -138,8 +145,8 @@ def test_merging_when_target_exists(test_ctx, fake_datetime, post_factory):
({'mergeTo': []}, tags.TagNotFoundError),
])
def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception):
- source_tag = test_ctx.tag_factory(names=['source'], category_name='meta')
- target_tag = test_ctx.tag_factory(names=['target'], category_name='meta')
+ source_tag = test_ctx.tag_factory(names=['source'])
+ target_tag = test_ctx.tag_factory(names=['target'])
db.session.add_all([source_tag, target_tag])
db.session.commit()
real_input = {
@@ -160,8 +167,8 @@ def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception):
'field', ['remove', 'mergeTo', 'removeVersion', 'mergeToVersion'])
def test_trying_to_omit_mandatory_field(test_ctx, field):
db.session.add_all([
- test_ctx.tag_factory(names=['source'], category_name='meta'),
- test_ctx.tag_factory(names=['target'], category_name='meta'),
+ test_ctx.tag_factory(names=['source']),
+ test_ctx.tag_factory(names=['target']),
])
db.session.commit()
input = {
@@ -178,7 +185,7 @@ def test_trying_to_omit_mandatory_field(test_ctx, field):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
def test_trying_to_merge_non_existing(test_ctx):
- db.session.add(test_ctx.tag_factory(names=['good'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['good']))
db.session.commit()
with pytest.raises(tags.TagNotFoundError):
test_ctx.api.post(
@@ -192,7 +199,7 @@ def test_trying_to_merge_non_existing(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
def test_trying_to_merge_to_itself(test_ctx):
- db.session.add(test_ctx.tag_factory(names=['good'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['good']))
db.session.commit()
with pytest.raises(tags.InvalidTagRelationError):
test_ctx.api.post(
@@ -212,8 +219,8 @@ def test_trying_to_merge_to_itself(test_ctx):
])
def test_trying_to_merge_without_privileges(test_ctx, input):
db.session.add_all([
- test_ctx.tag_factory(names=['source'], category_name='meta'),
- test_ctx.tag_factory(names=['target'], category_name='meta'),
+ test_ctx.tag_factory(names=['source']),
+ test_ctx.tag_factory(names=['target']),
])
db.session.commit()
with pytest.raises(errors.AuthError):
diff --git a/server/szurubooru/tests/api/test_tag_retrieving.py b/server/szurubooru/tests/api/test_tag_retrieving.py
index a81b9cd..0351e25 100644
--- a/server/szurubooru/tests/api/test_tag_retrieving.py
+++ b/server/szurubooru/tests/api/test_tag_retrieving.py
@@ -4,7 +4,12 @@ from szurubooru import api, db, errors
from szurubooru.func import util, tags
@pytest.fixture
-def test_ctx(context_factory, config_injector, user_factory, tag_factory):
+def test_ctx(
+ context_factory,
+ config_injector,
+ user_factory,
+ tag_factory,
+ tag_category_factory):
config_injector({
'privileges': {
'tags:list': db.User.RANK_REGULAR,
@@ -16,6 +21,7 @@ def test_ctx(context_factory, config_injector, user_factory, tag_factory):
ret.context_factory = context_factory
ret.user_factory = user_factory
ret.tag_factory = tag_factory
+ ret.tag_category_factory = tag_category_factory
ret.list_api = api.TagListApi()
ret.detail_api = api.TagDetailApi()
return ret
@@ -42,14 +48,15 @@ def test_trying_to_retrieve_multiple_without_privileges(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)))
def test_retrieving_single(test_ctx):
- db.session.add(test_ctx.tag_factory(names=['tag']))
+ category = test_ctx.tag_category_factory(name='meta')
+ db.session.add(test_ctx.tag_factory(names=['tag'], category=category))
result = test_ctx.detail_api.get(
test_ctx.context_factory(
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag')
assert result == {
'names': ['tag'],
- 'category': 'dummy',
+ 'category': 'meta',
'description': None,
'creationTime': datetime.datetime(1996, 1, 1),
'lastEditTime': None,
diff --git a/server/szurubooru/tests/api/test_tag_updating.py b/server/szurubooru/tests/api/test_tag_updating.py
index 163852c..3f3365a 100644
--- a/server/szurubooru/tests/api/test_tag_updating.py
+++ b/server/szurubooru/tests/api/test_tag_updating.py
@@ -2,7 +2,7 @@ import datetime
import os
import pytest
from szurubooru import api, config, db, errors
-from szurubooru.func import util, tags, tag_categories
+from szurubooru.func import util, tags, tag_categories, cache
def assert_relations(relations, expected_tag_names):
actual_names = sorted([rel.names[0].name for rel in relations])
@@ -26,7 +26,8 @@ def test_ctx(
})
db.session.add_all([
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
- db.session.flush()
+ db.session.commit()
+ cache.purge()
ret = util.dotdict()
ret.context_factory = context_factory
ret.user_factory = user_factory
@@ -35,7 +36,7 @@ def test_ctx(
return ret
def test_simple_updating(test_ctx, fake_datetime):
- tag = test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta')
+ tag = test_ctx.tag_factory(names=['tag1', 'tag2'])
db.session.add(tag)
db.session.commit()
with fake_datetime('1997-12-01'):
@@ -79,14 +80,14 @@ def test_simple_updating(test_ctx, fake_datetime):
({'names': ['']}, tags.InvalidTagNameError),
({'names': ['!bad']}, tags.InvalidTagNameError),
({'names': ['x' * 65]}, tags.InvalidTagNameError),
- ({'category': None}, tag_categories.InvalidTagCategoryNameError),
- ({'category': ''}, tag_categories.InvalidTagCategoryNameError),
- ({'category': '!bad'}, tag_categories.InvalidTagCategoryNameError),
+ ({'category': None}, tag_categories.TagCategoryNotFoundError),
+ ({'category': ''}, tag_categories.TagCategoryNotFoundError),
+ ({'category': '!bad'}, tag_categories.TagCategoryNotFoundError),
({'suggestions': ['good', '!bad']}, tags.InvalidTagNameError),
({'implications': ['good', '!bad']}, tags.InvalidTagNameError),
])
def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception):
- db.session.add(test_ctx.tag_factory(names=['tag1'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['tag1']))
db.session.commit()
with pytest.raises(expected_exception):
test_ctx.api.put(
@@ -98,7 +99,7 @@ def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception):
@pytest.mark.parametrize(
'field', ['names', 'category', 'description', 'implications', 'suggestions'])
def test_omitting_optional_field(test_ctx, field):
- db.session.add(test_ctx.tag_factory(names=['tag'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['tag']))
db.session.commit()
input = {
'names': ['tag1', 'tag2'],
@@ -126,7 +127,7 @@ def test_trying_to_update_non_existing(test_ctx):
@pytest.mark.parametrize('dup_name', ['tag1', 'TAG1'])
def test_reusing_own_name(test_ctx, dup_name):
db.session.add(
- test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta'))
+ test_ctx.tag_factory(names=['tag1', 'tag2']))
db.session.commit()
result = test_ctx.api.put(
test_ctx.context_factory(
@@ -142,7 +143,7 @@ def test_reusing_own_name(test_ctx, dup_name):
def test_duplicating_names(test_ctx):
db.session.add(
- test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta'))
+ test_ctx.tag_factory(names=['tag1', 'tag2']))
result = test_ctx.api.put(
test_ctx.context_factory(
input={'names': ['tag3', 'TAG3'], 'version': 1},
@@ -158,8 +159,8 @@ def test_duplicating_names(test_ctx):
@pytest.mark.parametrize('dup_name', ['tag1', 'TAG1', 'tag2', 'TAG2'])
def test_trying_to_use_existing_name(test_ctx, dup_name):
db.session.add_all([
- test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta'),
- test_ctx.tag_factory(names=['tag3', 'tag4'], category_name='meta')])
+ test_ctx.tag_factory(names=['tag1', 'tag2']),
+ test_ctx.tag_factory(names=['tag3', 'tag4'])])
db.session.commit()
with pytest.raises(tags.TagAlreadyExistsError):
test_ctx.api.put(
@@ -193,7 +194,7 @@ def test_trying_to_use_existing_name(test_ctx, dup_name):
def test_updating_new_suggestions_and_implications(
test_ctx, input, expected_suggestions, expected_implications):
db.session.add(
- test_ctx.tag_factory(names=['main'], category_name='meta'))
+ test_ctx.tag_factory(names=['main']))
db.session.commit()
result = test_ctx.api.put(
test_ctx.context_factory(
@@ -210,9 +211,9 @@ def test_updating_new_suggestions_and_implications(
def test_reusing_suggestions_and_implications(test_ctx):
db.session.add_all([
- test_ctx.tag_factory(names=['tag1', 'tag2'], category_name='meta'),
- test_ctx.tag_factory(names=['tag3'], category_name='meta'),
- test_ctx.tag_factory(names=['tag4'], category_name='meta'),
+ test_ctx.tag_factory(names=['tag1', 'tag2']),
+ test_ctx.tag_factory(names=['tag3']),
+ test_ctx.tag_factory(names=['tag4']),
])
db.session.commit()
result = test_ctx.api.put(
@@ -248,7 +249,7 @@ def test_reusing_suggestions_and_implications(test_ctx):
}
])
def test_trying_to_relate_tag_to_itself(test_ctx, input):
- db.session.add(test_ctx.tag_factory(names=['tag1'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['tag1']))
db.session.commit()
with pytest.raises(tags.InvalidTagRelationError):
test_ctx.api.put(
@@ -264,7 +265,7 @@ def test_trying_to_relate_tag_to_itself(test_ctx, input):
{'implications': ['whatever']},
])
def test_trying_to_update_without_privileges(test_ctx, input):
- db.session.add(test_ctx.tag_factory(names=['tag'], category_name='meta'))
+ db.session.add(test_ctx.tag_factory(names=['tag']))
db.session.commit()
with pytest.raises(errors.AuthError):
test_ctx.api.put(
diff --git a/server/szurubooru/tests/conftest.py b/server/szurubooru/tests/conftest.py
index f53b041..4fb3882 100644
--- a/server/szurubooru/tests/conftest.py
+++ b/server/szurubooru/tests/conftest.py
@@ -106,18 +106,19 @@ def user_factory():
@pytest.fixture
def tag_category_factory():
- def factory(name='dummy', color='dummy'):
+ def factory(name=None, color='dummy', default=False):
category = db.TagCategory()
- category.name = name
+ category.name = name or get_unique_name()
category.color = color
+ category.default = default
return category
return factory
@pytest.fixture
def tag_factory():
- def factory(names=None, category=None, category_name='dummy'):
+ def factory(names=None, category=None):
if not category:
- category = db.TagCategory(category_name)
+ category = db.TagCategory(get_unique_name())
db.session.add(category)
tag = db.Tag()
tag.names = [db.TagName(name) for name in (names or [get_unique_name()])]
diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py
index dde6f73..2a97b13 100644
--- a/server/szurubooru/tests/func/test_posts.py
+++ b/server/szurubooru/tests/func/test_posts.py
@@ -127,6 +127,7 @@ def test_serialize_post(
db.session.flush()
result = posts.serialize_post(post, auth_user)
+ result['tags'].sort()
assert result == {
'id': 1,
diff --git a/server/szurubooru/tests/func/test_snapshots.py b/server/szurubooru/tests/func/test_snapshots.py
index c82b82f..c223f93 100644
--- a/server/szurubooru/tests/func/test_snapshots.py
+++ b/server/szurubooru/tests/func/test_snapshots.py
@@ -62,8 +62,9 @@ def test_serializing_post(post_factory, user_factory, tag_factory):
}
-def test_serializing_tag(tag_factory):
- tag = tag_factory(names=['main_name', 'alias'], category_name='dummy')
+def test_serializing_tag(tag_factory, tag_category_factory):
+ category = tag_category_factory(name='dummy')
+ tag = tag_factory(names=['main_name', 'alias'], category=category)
assert snapshots.get_tag_snapshot(tag) == {
'names': ['main_name', 'alias'],
'category': 'dummy',
@@ -71,7 +72,7 @@ def test_serializing_tag(tag_factory):
'implications': [],
}
- tag = tag_factory(names=['main_name', 'alias'], category_name='dummy')
+ tag = tag_factory(names=['main_name', 'alias'], category=category)
imp1 = tag_factory(names=['imp1_main_name', 'imp1_alias'])
imp2 = tag_factory(names=['imp2_main_name', 'imp2_alias'])
sug1 = tag_factory(names=['sug1_main_name', 'sug1_alias'])
@@ -196,8 +197,13 @@ def test_merging_resets_merging_time_window(
'initial_operation',
[snapshots.save_entity_creation, snapshots.save_entity_modification])
def test_merging_deletion_to_modification_or_creation(
- fake_datetime, tag_factory, user_factory, initial_operation):
- tag = tag_factory(names=['dummy'], category_name='dummy')
+ fake_datetime,
+ tag_factory,
+ tag_category_factory,
+ user_factory,
+ initial_operation):
+ category = tag_category_factory(name='dummy')
+ tag = tag_factory(names=['dummy'], category=category)
user = user_factory()
db.session.add_all([tag, user])
db.session.flush()
@@ -241,8 +247,10 @@ def test_merging_deletion_all_the_way_deletes_all_snapshots(
snapshots.save_entity_deletion(tag, user)
assert db.session.query(db.Snapshot).count() == 0
-def test_get_serialized_history(fake_datetime, tag_factory, user_factory):
- tag = tag_factory(names=['dummy'])
+def test_get_serialized_history(
+ fake_datetime, tag_factory, tag_category_factory, user_factory):
+ category = tag_category_factory(name='dummy')
+ tag = tag_factory(names=['dummy'], category=category)
user = user_factory(name='the-user')
db.session.add_all([tag, user])
db.session.flush()

© 2015 - 2026 Jakob L. Kreuze