aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/tests/conftest.py
diff options
context:
space:
mode:
authorrr-2016-04-24 09:50:11 +0200
committerrr-2016-04-24 10:31:49 +0200
commit612734e9ff7b6ca500bbf8247314804e1f806a09 (patch)
treea097000d617684633b15368f13610f81d3aafe80 /server/szurubooru/tests/conftest.py
parent6e6c57d44a3255f277542d01a9de7c3decfe1c4c (diff)
server/comments: add comment creating
Diffstat (limited to 'server/szurubooru/tests/conftest.py')
-rw-r--r--server/szurubooru/tests/conftest.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/server/szurubooru/tests/conftest.py b/server/szurubooru/tests/conftest.py
index f99934d..be4162d 100644
--- a/server/szurubooru/tests/conftest.py
+++ b/server/szurubooru/tests/conftest.py
@@ -101,7 +101,7 @@ def user_factory():
return factory
@pytest.fixture
-def tag_category_factory(session):
+def tag_category_factory():
def factory(name='dummy', color='dummy'):
category = db.TagCategory()
category.name = name
@@ -110,11 +110,11 @@ def tag_category_factory(session):
return factory
@pytest.fixture
-def tag_factory(session):
+def tag_factory():
def factory(names=None, category=None, category_name='dummy'):
if not category:
category = db.TagCategory(category_name)
- session.add(category)
+ db.session.add(category)
tag = db.Tag()
tag.names = [db.TagName(name) for name in (names or [get_unique_name()])]
tag.category = category
@@ -140,11 +140,17 @@ def post_factory():
return factory
@pytest.fixture
-def comment_factory():
+def comment_factory(user_factory, post_factory):
def factory(user=None, post=None, text='dummy'):
+ if not user:
+ user = user_factory()
+ db.session.add(user)
+ if not post:
+ post = post_factory()
+ db.session.add(post)
comment = db.Comment()
- comment.user = user or user_factory()
- comment.post = post or post_factory()
+ comment.user = user
+ comment.post = post
comment.text = text
comment.creation_time = datetime.datetime(1996, 1, 1)
return comment

© 2015 - 2026 Jakob L. Kreuze