summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2016-05-30 22:20:42 +0200
committerrr- <rr-@sakuya.pl>2016-05-30 22:54:33 +0200
commit8d1e23aa63370ed2e14deaa8fef9eca11ad31eae (patch)
treea25e91c491e1de4436a8a5428f14f201f697a54b /server
parentd0314813cb284cbe50101fcea32bf7126a59ba74 (diff)
server/general: flatten responses
Diffstat (limited to 'server')
-rw-r--r--server/szurubooru/api/comment_api.py10
-rw-r--r--server/szurubooru/api/post_api.py18
-rw-r--r--server/szurubooru/api/tag_api.py8
-rw-r--r--server/szurubooru/api/tag_category_api.py8
-rw-r--r--server/szurubooru/api/user_api.py7
-rw-r--r--server/szurubooru/tests/api/test_comment_creating.py10
-rw-r--r--server/szurubooru/tests/api/test_comment_rating.py3
-rw-r--r--server/szurubooru/tests/api/test_comment_retrieving.py15
-rw-r--r--server/szurubooru/tests/api/test_comment_updating.py2
-rw-r--r--server/szurubooru/tests/api/test_post_creating.py4
-rw-r--r--server/szurubooru/tests/api/test_post_favoriting.py3
-rw-r--r--server/szurubooru/tests/api/test_post_featuring.py16
-rw-r--r--server/szurubooru/tests/api/test_post_rating.py3
-rw-r--r--server/szurubooru/tests/api/test_post_retrieving.py7
-rw-r--r--server/szurubooru/tests/api/test_post_updating.py2
-rw-r--r--server/szurubooru/tests/api/test_tag_category_creating.py6
-rw-r--r--server/szurubooru/tests/api/test_tag_category_retrieving.py12
-rw-r--r--server/szurubooru/tests/api/test_tag_category_updating.py8
-rw-r--r--server/szurubooru/tests/api/test_tag_creating.py18
-rw-r--r--server/szurubooru/tests/api/test_tag_merging.py6
-rw-r--r--server/szurubooru/tests/api/test_tag_retrieving.py18
-rw-r--r--server/szurubooru/tests/api/test_tag_updating.py18
-rw-r--r--server/szurubooru/tests/api/test_user_creating.py29
-rw-r--r--server/szurubooru/tests/api/test_user_retrieving.py18
-rw-r--r--server/szurubooru/tests/api/test_user_updating.py20
25 files changed, 125 insertions, 144 deletions
diff --git a/server/szurubooru/api/comment_api.py b/server/szurubooru/api/comment_api.py
index b0e0074..8aeacec 100644
--- a/server/szurubooru/api/comment_api.py
+++ b/server/szurubooru/api/comment_api.py
@@ -23,13 +23,13 @@ class CommentListApi(BaseApi):
comment = comments.create_comment(ctx.user, post, text)
ctx.session.add(comment)
ctx.session.commit()
- return {'comment': comments.serialize_comment(comment, ctx.user)}
+ return comments.serialize_comment(comment, ctx.user)
class CommentDetailApi(BaseApi):
def get(self, ctx, comment_id):
auth.verify_privilege(ctx.user, 'comments:view')
comment = comments.get_comment_by_id(comment_id)
- return {'comment': comments.serialize_comment(comment, ctx.user)}
+ return comments.serialize_comment(comment, ctx.user)
def put(self, ctx, comment_id):
comment = comments.get_comment_by_id(comment_id)
@@ -39,7 +39,7 @@ class CommentDetailApi(BaseApi):
comment.last_edit_time = datetime.datetime.now()
comments.update_comment_text(comment, text)
ctx.session.commit()
- return {'comment': comments.serialize_comment(comment, ctx.user)}
+ return comments.serialize_comment(comment, ctx.user)
def delete(self, ctx, comment_id):
comment = comments.get_comment_by_id(comment_id)
@@ -56,11 +56,11 @@ class CommentScoreApi(BaseApi):
comment = comments.get_comment_by_id(comment_id)
scores.set_score(comment, ctx.user, score)
ctx.session.commit()
- return {'comment': comments.serialize_comment(comment, ctx.user)}
+ return comments.serialize_comment(comment, ctx.user)
def delete(self, ctx, comment_id):
auth.verify_privilege(ctx.user, 'comments:score')
comment = comments.get_comment_by_id(comment_id)
scores.delete_score(comment, ctx.user)
ctx.session.commit()
- return {'comment': comments.serialize_comment(comment, ctx.user)}
+ return comments.serialize_comment(comment, ctx.user)
diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py
index b7bdafe..3f0eb94 100644
--- a/server/szurubooru/api/post_api.py
+++ b/server/szurubooru/api/post_api.py
@@ -38,13 +38,13 @@ class PostListApi(BaseApi):
snapshots.save_entity_creation(post, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
class PostDetailApi(BaseApi):
def get(self, ctx, post_id):
auth.verify_privilege(ctx.user, 'posts:view')
post = posts.get_post_by_id(post_id)
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
def put(self, ctx, post_id):
post = posts.get_post_by_id(post_id)
@@ -79,7 +79,7 @@ class PostDetailApi(BaseApi):
snapshots.save_entity_modification(post, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
def delete(self, ctx, post_id):
auth.verify_privilege(ctx.user, 'posts:delete')
@@ -104,11 +104,11 @@ class PostFeatureApi(BaseApi):
snapshots.save_entity_modification(featured_post, ctx.user)
snapshots.save_entity_modification(post, ctx.user)
ctx.session.commit()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
def get(self, ctx):
post = posts.try_get_featured_post()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
class PostScoreApi(BaseApi):
def put(self, ctx, post_id):
@@ -117,14 +117,14 @@ class PostScoreApi(BaseApi):
score = ctx.get_param_as_int('score', required=True)
scores.set_score(post, ctx.user, score)
ctx.session.commit()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
def delete(self, ctx, post_id):
auth.verify_privilege(ctx.user, 'posts:score')
post = posts.get_post_by_id(post_id)
scores.delete_score(post, ctx.user)
ctx.session.commit()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
class PostFavoriteApi(BaseApi):
def post(self, ctx, post_id):
@@ -132,11 +132,11 @@ class PostFavoriteApi(BaseApi):
post = posts.get_post_by_id(post_id)
favorites.set_favorite(post, ctx.user)
ctx.session.commit()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
def delete(self, ctx, post_id):
auth.verify_privilege(ctx.user, 'posts:favorite')
post = posts.get_post_by_id(post_id)
favorites.unset_favorite(post, ctx.user)
ctx.session.commit()
- return {'post': posts.serialize_post(post, ctx.user)}
+ return posts.serialize_post(post, ctx.user)
diff --git a/server/szurubooru/api/tag_api.py b/server/szurubooru/api/tag_api.py
index 6dc7946..65cecf9 100644
--- a/server/szurubooru/api/tag_api.py
+++ b/server/szurubooru/api/tag_api.py
@@ -41,13 +41,13 @@ class TagListApi(BaseApi):
snapshots.save_entity_creation(tag, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'tag': tags.serialize_tag(tag)}
+ return tags.serialize_tag(tag)
class TagDetailApi(BaseApi):
def get(self, ctx, tag_name):
auth.verify_privilege(ctx.user, 'tags:view')
tag = tags.get_tag_by_name(tag_name)
- return {'tag': tags.serialize_tag(tag)}
+ return tags.serialize_tag(tag)
def put(self, ctx, tag_name):
tag = tags.get_tag_by_name(tag_name)
@@ -73,7 +73,7 @@ class TagDetailApi(BaseApi):
snapshots.save_entity_modification(tag, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'tag': tags.serialize_tag(tag)}
+ return tags.serialize_tag(tag)
def delete(self, ctx, tag_name):
tag = tags.get_tag_by_name(tag_name)
@@ -101,7 +101,7 @@ class TagMergeApi(BaseApi):
tags.merge_tags(source_tag, target_tag)
ctx.session.commit()
tags.export_to_json()
- return {'tag': tags.serialize_tag(target_tag)}
+ return tags.serialize_tag(target_tag)
class TagSiblingsApi(BaseApi):
def get(self, ctx, tag_name):
diff --git a/server/szurubooru/api/tag_category_api.py b/server/szurubooru/api/tag_category_api.py
index 2da8343..ffae5e0 100644
--- a/server/szurubooru/api/tag_category_api.py
+++ b/server/szurubooru/api/tag_category_api.py
@@ -21,13 +21,13 @@ class TagCategoryListApi(BaseApi):
snapshots.save_entity_creation(category, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'tagCategory': tag_categories.serialize_category(category)}
+ return tag_categories.serialize_category(category)
class TagCategoryDetailApi(BaseApi):
def get(self, ctx, category_name):
auth.verify_privilege(ctx.user, 'tag_categories:view')
category = tag_categories.get_category_by_name(category_name)
- return {'tagCategory': tag_categories.serialize_category(category)}
+ return tag_categories.serialize_category(category)
def put(self, ctx, category_name):
category = tag_categories.get_category_by_name(category_name)
@@ -43,7 +43,7 @@ class TagCategoryDetailApi(BaseApi):
snapshots.save_entity_modification(category, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'tagCategory': tag_categories.serialize_category(category)}
+ return tag_categories.serialize_category(category)
def delete(self, ctx, category_name):
category = tag_categories.get_category_by_name(category_name)
@@ -69,4 +69,4 @@ class DefaultTagCategoryApi(BaseApi):
snapshots.save_entity_modification(category, ctx.user)
ctx.session.commit()
tags.export_to_json()
- return {'tagCategory': tag_categories.serialize_category(category)}
+ return tag_categories.serialize_category(category)
diff --git a/server/szurubooru/api/user_api.py b/server/szurubooru/api/user_api.py
index 9870b4f..29371ce 100644
--- a/server/szurubooru/api/user_api.py
+++ b/server/szurubooru/api/user_api.py
@@ -28,14 +28,13 @@ class UserListApi(BaseApi):
ctx.get_file('avatar'))
ctx.session.add(user)
ctx.session.commit()
- return {'user': users.serialize_user(
- user, ctx.user, force_show_email=True)}
+ return users.serialize_user(user, ctx.user, force_show_email=True)
class UserDetailApi(BaseApi):
def get(self, ctx, user_name):
auth.verify_privilege(ctx.user, 'users:view')
user = users.get_user_by_name(user_name)
- return {'user': users.serialize_user(user, ctx.user)}
+ return users.serialize_user(user, ctx.user)
def put(self, ctx, user_name):
user = users.get_user_by_name(user_name)
@@ -61,7 +60,7 @@ class UserDetailApi(BaseApi):
ctx.get_param_as_string('avatarStyle'),
ctx.get_file('avatar'))
ctx.session.commit()
- return {'user': users.serialize_user(user, ctx.user)}
+ return users.serialize_user(user, ctx.user)
def delete(self, ctx, user_name):
user = users.get_user_by_name(user_name)
diff --git a/server/szurubooru/tests/api/test_comment_creating.py b/server/szurubooru/tests/api/test_comment_creating.py
index 2a14835..00a9de6 100644
--- a/server/szurubooru/tests/api/test_comment_creating.py
+++ b/server/szurubooru/tests/api/test_comment_creating.py
@@ -29,11 +29,11 @@ def test_creating_comment(test_ctx, fake_datetime):
test_ctx.context_factory(
input={'text': 'input', 'postId': post.post_id},
user=user))
- assert result['comment']['text'] == 'input'
- assert 'id' in result['comment']
- assert 'user' in result['comment']
- assert 'name' in result['comment']['user']
- assert 'postId' in result['comment']
+ assert result['text'] == 'input'
+ assert 'id' in result
+ assert 'user' in result
+ assert 'name' in result['user']
+ assert 'postId' in result
comment = db.session.query(db.Comment).one()
assert comment.text == 'input'
assert comment.creation_time == datetime.datetime(1997, 1, 1)
diff --git a/server/szurubooru/tests/api/test_comment_rating.py b/server/szurubooru/tests/api/test_comment_rating.py
index c0a00cc..6a8360a 100644
--- a/server/szurubooru/tests/api/test_comment_rating.py
+++ b/server/szurubooru/tests/api/test_comment_rating.py
@@ -32,8 +32,7 @@ def test_simple_rating(test_ctx, fake_datetime):
result = test_ctx.api.put(
test_ctx.context_factory(input={'score': 1}, user=user),
comment.comment_id)
- assert 'comment' in result
- assert 'text' in result['comment']
+ assert 'text' in result
comment = db.session.query(db.Comment).one()
assert db.session.query(db.CommentScore).count() == 1
assert comment is not None
diff --git a/server/szurubooru/tests/api/test_comment_retrieving.py b/server/szurubooru/tests/api/test_comment_retrieving.py
index 5f70b42..3338d1b 100644
--- a/server/szurubooru/tests/api/test_comment_retrieving.py
+++ b/server/szurubooru/tests/api/test_comment_retrieving.py
@@ -53,14 +53,13 @@ def test_retrieving_single(test_ctx):
test_ctx.context_factory(
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
comment.comment_id)
- assert 'comment' in result
- assert 'id' in result['comment']
- assert 'lastEditTime' in result['comment']
- assert 'creationTime' in result['comment']
- assert 'text' in result['comment']
- assert 'user' in result['comment']
- assert 'name' in result['comment']['user']
- assert 'postId' in result['comment']
+ assert 'id' in result
+ assert 'lastEditTime' in result
+ assert 'creationTime' in result
+ assert 'text' in result
+ assert 'user' in result
+ assert 'name' in result['user']
+ assert 'postId' in result
def test_trying_to_retrieve_single_non_existing(test_ctx):
with pytest.raises(comments.CommentNotFoundError):
diff --git a/server/szurubooru/tests/api/test_comment_updating.py b/server/szurubooru/tests/api/test_comment_updating.py
index 37831aa..7582246 100644
--- a/server/szurubooru/tests/api/test_comment_updating.py
+++ b/server/szurubooru/tests/api/test_comment_updating.py
@@ -33,7 +33,7 @@ def test_simple_updating(test_ctx, fake_datetime):
result = test_ctx.api.put(
test_ctx.context_factory(input={'text': 'new text'}, user=user),
comment.comment_id)
- assert result['comment']['text'] == 'new text'
+ assert result['text'] == 'new text'
comment = db.session.query(db.Comment).one()
assert comment is not None
assert comment.text == 'new text'
diff --git a/server/szurubooru/tests/api/test_post_creating.py b/server/szurubooru/tests/api/test_post_creating.py
index d049a6b..adb0b20 100644
--- a/server/szurubooru/tests/api/test_post_creating.py
+++ b/server/szurubooru/tests/api/test_post_creating.py
@@ -44,7 +44,7 @@ def test_creating_minimal_posts(
},
user=auth_user))
- assert result == {'post': 'serialized post'}
+ assert result == 'serialized post'
posts.create_post.assert_called_once_with(
'post-content', ['tag1', 'tag2'], auth_user)
posts.update_post_thumbnail.assert_called_once_with(post, 'post-thumbnail')
@@ -92,7 +92,7 @@ def test_creating_full_posts(context_factory, post_factory, user_factory):
},
user=auth_user))
- assert result == {'post': 'serialized post'}
+ assert result == 'serialized post'
posts.create_post.assert_called_once_with(
'post-content', ['tag1', 'tag2'], auth_user)
posts.update_post_safety.assert_called_once_with(post, 'safe')
diff --git a/server/szurubooru/tests/api/test_post_favoriting.py b/server/szurubooru/tests/api/test_post_favoriting.py
index 00a1035..0e24a01 100644
--- a/server/szurubooru/tests/api/test_post_favoriting.py
+++ b/server/szurubooru/tests/api/test_post_favoriting.py
@@ -32,8 +32,7 @@ def test_adding_to_favorites(test_ctx, fake_datetime):
result = test_ctx.api.post(
test_ctx.context_factory(user=test_ctx.user_factory()),
post.post_id)
- assert 'post' in result
- assert 'id' in result['post']
+ assert 'id' in result
post = db.session.query(db.Post).one()
assert db.session.query(db.PostFavorite).count() == 1
assert post is not None
diff --git a/server/szurubooru/tests/api/test_post_featuring.py b/server/szurubooru/tests/api/test_post_featuring.py
index ad56e58..fbd6e45 100644
--- a/server/szurubooru/tests/api/test_post_featuring.py
+++ b/server/szurubooru/tests/api/test_post_featuring.py
@@ -26,7 +26,7 @@ def test_no_featured_post(test_ctx):
result = test_ctx.api.get(
test_ctx.context_factory(
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert result == {'post': None}
+ assert result is None
def test_featuring(test_ctx):
db.session.add(test_ctx.post_factory(id=1))
@@ -39,17 +39,15 @@ def test_featuring(test_ctx):
assert posts.try_get_featured_post() is not None
assert posts.try_get_featured_post().post_id == 1
assert posts.get_post_by_id(1).is_featured
- assert 'post' in result
- assert 'id' in result['post']
- assert 'snapshots' in result['post']
- assert 'comments' in result['post']
+ assert 'id' in result
+ assert 'snapshots' in result
+ assert 'comments' in result
result = test_ctx.api.get(
test_ctx.context_factory(
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert 'post' in result
- assert 'id' in result['post']
- assert 'snapshots' in result['post']
- assert 'comments' in result['post']
+ assert 'id' in result
+ assert 'snapshots' in result
+ assert 'comments' in result
def test_trying_to_feature_the_same_post_twice(test_ctx):
db.session.add(test_ctx.post_factory(id=1))
diff --git a/server/szurubooru/tests/api/test_post_rating.py b/server/szurubooru/tests/api/test_post_rating.py
index a48830e..fd63115 100644
--- a/server/szurubooru/tests/api/test_post_rating.py
+++ b/server/szurubooru/tests/api/test_post_rating.py
@@ -28,8 +28,7 @@ def test_simple_rating(test_ctx, fake_datetime):
test_ctx.context_factory(
input={'score': 1}, user=test_ctx.user_factory()),
post.post_id)
- assert 'post' in result
- assert 'id' in result['post']
+ assert 'id' in result
post = db.session.query(db.Post).one()
assert db.session.query(db.PostScore).count() == 1
assert post is not None
diff --git a/server/szurubooru/tests/api/test_post_retrieving.py b/server/szurubooru/tests/api/test_post_retrieving.py
index 3ceff64..41c6ead 100644
--- a/server/szurubooru/tests/api/test_post_retrieving.py
+++ b/server/szurubooru/tests/api/test_post_retrieving.py
@@ -79,10 +79,9 @@ def test_retrieving_single(test_ctx):
result = test_ctx.detail_api.get(
test_ctx.context_factory(
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)), 1)
- assert 'post' in result
- assert 'id' in result['post']
- assert 'snapshots' in result['post']
- assert 'comments' in result['post']
+ assert 'id' in result
+ assert 'snapshots' in result
+ assert 'comments' in result
def test_trying_to_retrieve_single_non_existing(test_ctx):
with pytest.raises(posts.PostNotFoundError):
diff --git a/server/szurubooru/tests/api/test_post_updating.py b/server/szurubooru/tests/api/test_post_updating.py
index 7f1b425..fc14c27 100644
--- a/server/szurubooru/tests/api/test_post_updating.py
+++ b/server/szurubooru/tests/api/test_post_updating.py
@@ -57,7 +57,7 @@ def test_post_updating(
user=auth_user),
post.post_id)
- assert result == {'post': 'serialized post'}
+ assert result == 'serialized post'
posts.create_post.assert_not_called()
posts.update_post_tags.assert_called_once_with(post, ['tag1', 'tag2'])
posts.update_post_content.assert_called_once_with(post, 'post-content')
diff --git a/server/szurubooru/tests/api/test_tag_category_creating.py b/server/szurubooru/tests/api/test_tag_category_creating.py
index dc43bf8..18b57dc 100644
--- a/server/szurubooru/tests/api/test_tag_category_creating.py
+++ b/server/szurubooru/tests/api/test_tag_category_creating.py
@@ -21,9 +21,9 @@ def test_creating_category(test_ctx):
test_ctx.context_factory(
input={'name': 'meta', 'color': 'black'},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert len(result['tagCategory']['snapshots']) == 1
- del result['tagCategory']['snapshots']
- assert result['tagCategory'] == {
+ assert len(result['snapshots']) == 1
+ del result['snapshots']
+ assert result == {
'name': 'meta',
'color': 'black',
'usages': 0,
diff --git a/server/szurubooru/tests/api/test_tag_category_retrieving.py b/server/szurubooru/tests/api/test_tag_category_retrieving.py
index 5353754..5644685 100644
--- a/server/szurubooru/tests/api/test_tag_category_retrieving.py
+++ b/server/szurubooru/tests/api/test_tag_category_retrieving.py
@@ -38,13 +38,11 @@ def test_retrieving_single(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'cat')
assert result == {
- 'tagCategory': {
- 'name': 'cat',
- 'color': 'dummy',
- 'usages': 0,
- 'default': False,
- 'snapshots': [],
- },
+ 'name': 'cat',
+ 'color': 'dummy',
+ 'usages': 0,
+ 'default': False,
+ 'snapshots': [],
}
def test_trying_to_retrieve_single_non_existing(test_ctx):
diff --git a/server/szurubooru/tests/api/test_tag_category_updating.py b/server/szurubooru/tests/api/test_tag_category_updating.py
index 7ff8bb4..045faa2 100644
--- a/server/szurubooru/tests/api/test_tag_category_updating.py
+++ b/server/szurubooru/tests/api/test_tag_category_updating.py
@@ -37,9 +37,9 @@ def test_simple_updating(test_ctx):
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'name')
- assert len(result['tagCategory']['snapshots']) == 1
- del result['tagCategory']['snapshots']
- assert result['tagCategory'] == {
+ assert len(result['snapshots']) == 1
+ del result['snapshots']
+ assert result == {
'name': 'changed',
'color': 'white',
'usages': 0,
@@ -103,7 +103,7 @@ def test_reusing_own_name(test_ctx, new_name):
input={'name': new_name},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'cat')
- assert result['tagCategory']['name'] == new_name
+ assert result['name'] == new_name
category = tag_categories.get_category_by_name('cat')
assert category.name == new_name
diff --git a/server/szurubooru/tests/api/test_tag_creating.py b/server/szurubooru/tests/api/test_tag_creating.py
index e2dec09..14269f5 100644
--- a/server/szurubooru/tests/api/test_tag_creating.py
+++ b/server/szurubooru/tests/api/test_tag_creating.py
@@ -38,9 +38,9 @@ def test_creating_simple_tags(test_ctx, fake_datetime):
'implications': [],
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert len(result['tag']['snapshots']) == 1
- del result['tag']['snapshots']
- assert result['tag'] == {
+ assert len(result['snapshots']) == 1
+ del result['snapshots']
+ assert result == {
'names': ['tag1', 'tag2'],
'category': 'meta',
'suggestions': [],
@@ -126,8 +126,8 @@ def test_duplicating_names(test_ctx):
'implications': [],
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert result['tag']['names'] == ['tag1']
- assert result['tag']['category'] == 'meta'
+ assert result['names'] == ['tag1']
+ assert result['category'] == 'meta'
tag = tags.get_tag_by_name('tag1')
assert [tag_name.name for tag_name in tag.names] == ['tag1']
@@ -205,8 +205,8 @@ def test_creating_new_suggestions_and_implications(
result = test_ctx.api.post(
test_ctx.context_factory(
input=input, user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert result['tag']['suggestions'] == expected_suggestions
- assert result['tag']['implications'] == expected_implications
+ assert result['suggestions'] == expected_suggestions
+ assert result['implications'] == expected_implications
tag = tags.get_tag_by_name('main')
assert_relations(tag.suggestions, expected_suggestions)
assert_relations(tag.implications, expected_implications)
@@ -229,8 +229,8 @@ def test_reusing_suggestions_and_implications(test_ctx):
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
# NOTE: it should export only the first name
- assert result['tag']['suggestions'] == ['tag1']
- assert result['tag']['implications'] == ['tag1']
+ assert result['suggestions'] == ['tag1']
+ assert result['implications'] == ['tag1']
tag = tags.get_tag_by_name('new')
assert_relations(tag.suggestions, ['tag1'])
assert_relations(tag.implications, ['tag1'])
diff --git a/server/szurubooru/tests/api/test_tag_merging.py b/server/szurubooru/tests/api/test_tag_merging.py
index 39c79e4..54a4243 100644
--- a/server/szurubooru/tests/api/test_tag_merging.py
+++ b/server/szurubooru/tests/api/test_tag_merging.py
@@ -33,9 +33,9 @@ def test_merging_without_usages(test_ctx, fake_datetime):
'mergeTo': 'target',
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
- assert 'snapshots' in result['tag']
- del result['tag']['snapshots']
- assert result['tag'] == {
+ assert 'snapshots' in result
+ del result['snapshots']
+ assert result == {
'names': ['target'],
'category': 'meta',
'suggestions': [],
diff --git a/server/szurubooru/tests/api/test_tag_retrieving.py b/server/szurubooru/tests/api/test_tag_retrieving.py
index d475019..20c3003 100644
--- a/server/szurubooru/tests/api/test_tag_retrieving.py
+++ b/server/szurubooru/tests/api/test_tag_retrieving.py
@@ -48,16 +48,14 @@ def test_retrieving_single(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag')
assert result == {
- 'tag': {
- 'names': ['tag'],
- 'category': 'dummy',
- 'creationTime': datetime.datetime(1996, 1, 1),
- 'lastEditTime': None,
- 'suggestions': [],
- 'implications': [],
- 'usages': 0,
- 'snapshots': [],
- },
+ 'names': ['tag'],
+ 'category': 'dummy',
+ 'creationTime': datetime.datetime(1996, 1, 1),
+ 'lastEditTime': None,
+ 'suggestions': [],
+ 'implications': [],
+ 'usages': 0,
+ 'snapshots': [],
}
def test_trying_to_retrieve_single_non_existing(test_ctx):
diff --git a/server/szurubooru/tests/api/test_tag_updating.py b/server/szurubooru/tests/api/test_tag_updating.py
index 9647d21..9400fb9 100644
--- a/server/szurubooru/tests/api/test_tag_updating.py
+++ b/server/szurubooru/tests/api/test_tag_updating.py
@@ -46,9 +46,9 @@ def test_simple_updating(test_ctx, fake_datetime):
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag1')
- assert len(result['tag']['snapshots']) == 1
- del result['tag']['snapshots']
- assert result['tag'] == {
+ assert len(result['snapshots']) == 1
+ del result['snapshots']
+ assert result == {
'names': ['tag3'],
'category': 'character',
'suggestions': [],
@@ -127,7 +127,7 @@ def test_reusing_own_name(test_ctx, dup_name):
input={'names': [dup_name, 'tag3']},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag1')
- assert result['tag']['names'] == ['tag1', 'tag3']
+ assert result['names'] == ['tag1', 'tag3']
assert tags.try_get_tag_by_name('tag2') is None
tag1 = tags.get_tag_by_name('tag1')
tag2 = tags.get_tag_by_name('tag3')
@@ -142,7 +142,7 @@ def test_duplicating_names(test_ctx):
input={'names': ['tag3', 'TAG3']},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag1')
- assert result['tag']['names'] == ['tag3']
+ assert result['names'] == ['tag3']
assert tags.try_get_tag_by_name('tag1') is None
assert tags.try_get_tag_by_name('tag2') is None
tag = tags.get_tag_by_name('tag3')
@@ -193,8 +193,8 @@ def test_updating_new_suggestions_and_implications(
test_ctx.context_factory(
input=input, user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'main')
- assert result['tag']['suggestions'] == expected_suggestions
- assert result['tag']['implications'] == expected_implications
+ assert result['suggestions'] == expected_suggestions
+ assert result['implications'] == expected_implications
tag = tags.get_tag_by_name('main')
assert_relations(tag.suggestions, expected_suggestions)
assert_relations(tag.implications, expected_implications)
@@ -219,8 +219,8 @@ def test_reusing_suggestions_and_implications(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'tag4')
# NOTE: it should export only the first name
- assert result['tag']['suggestions'] == ['tag1']
- assert result['tag']['implications'] == ['tag1']
+ assert result['suggestions'] == ['tag1']
+ assert result['implications'] == ['tag1']
tag = tags.get_tag_by_name('new')
assert_relations(tag.suggestions, ['tag1'])
assert_relations(tag.implications, ['tag1'])
diff --git a/server/szurubooru/tests/api/test_user_creating.py b/server/szurubooru/tests/api/test_user_creating.py
index 127c612..c512b8b 100644
--- a/server/szurubooru/tests/api/test_user_creating.py
+++ b/server/szurubooru/tests/api/test_user_creating.py
@@ -35,16 +35,14 @@ def test_creating_user(test_ctx, fake_datetime):
},
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)))
assert result == {
- 'user': {
- 'avatarStyle': 'gravatar',
- 'avatarUrl': 'http://gravatar.com/avatar/' +
- '6f370c8c7109534c3d5c394123a477d7?d=retro&s=200',
- 'creationTime': datetime.datetime(1969, 2, 12),
- 'lastLoginTime': None,
- 'name': 'chewie1',
- 'rank': 'administrator',
- 'email': 'asd@asd.asd',
- }
+ 'avatarStyle': 'gravatar',
+ 'avatarUrl': 'http://gravatar.com/avatar/' +
+ '6f370c8c7109534c3d5c394123a477d7?d=retro&s=200',
+ 'creationTime': datetime.datetime(1969, 2, 12),
+ 'lastLoginTime': None,
+ 'name': 'chewie1',
+ 'rank': 'administrator',
+ 'email': 'asd@asd.asd',
}
user = users.get_user_by_name('chewie1')
assert user.name == 'chewie1'
@@ -70,8 +68,8 @@ def test_first_user_becomes_admin_others_not(test_ctx):
'password': 'sok',
},
user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)))
- assert result1['user']['rank'] == 'administrator'
- assert result2['user']['rank'] == 'regular'
+ assert result1['rank'] == 'administrator'
+ assert result2['rank'] == 'regular'
first_user = users.get_user_by_name('chewie1')
other_user = users.get_user_by_name('chewie2')
assert first_user.rank == db.User.RANK_ADMINISTRATOR
@@ -87,7 +85,7 @@ def test_first_user_does_not_become_admin_if_they_dont_wish_so(test_ctx):
'rank': 'regular',
},
user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)))
- assert result['user']['rank'] == 'regular'
+ assert result['rank'] == 'regular'
def test_trying_to_become_someone_else(test_ctx):
test_ctx.api.post(
@@ -208,7 +206,7 @@ def test_admin_creating_mod_account(test_ctx):
'rank': 'moderator',
}, user=user)
result = test_ctx.api.post(context)
- assert result['user']['rank'] == 'moderator'
+ assert result['rank'] == 'moderator'
def test_uploading_avatar(test_ctx, tmpdir):
config.config['data_dir'] = str(tmpdir.mkdir('data'))
@@ -225,5 +223,4 @@ def test_uploading_avatar(test_ctx, tmpdir):
user=test_ctx.user_factory(rank=db.User.RANK_MODERATOR)))
user = users.get_user_by_name('chewie')
assert user.avatar_style == user.AVATAR_MANUAL
- assert response['user']['avatarUrl'] == \
- 'http://example.com/data/avatars/chewie.png'
+ assert response['avatarUrl'] == 'http://example.com/data/avatars/chewie.png'
diff --git a/server/szurubooru/tests/api/test_user_retrieving.py b/server/szurubooru/tests/api/test_user_retrieving.py
index 8ad39b2..4058916 100644
--- a/server/szurubooru/tests/api/test_user_retrieving.py
+++ b/server/szurubooru/tests/api/test_user_retrieving.py
@@ -48,16 +48,14 @@ def test_retrieving_single(test_ctx):
user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)),
'u1')
assert result == {
- 'user': {
- 'name': 'u1',
- 'rank': db.User.RANK_REGULAR,
- 'creationTime': datetime.datetime(1997, 1, 1),
- 'lastLoginTime': None,
- 'avatarStyle': 'gravatar',
- 'avatarUrl': 'http://gravatar.com/avatar/' +
- '275876e34cf609db118f3d84b799a790?d=retro&s=200',
- 'email': False,
- }
+ 'name': 'u1',
+ 'rank': db.User.RANK_REGULAR,
+ 'creationTime': datetime.datetime(1997, 1, 1),
+ 'lastLoginTime': None,
+ 'avatarStyle': 'gravatar',
+ 'avatarUrl': 'http://gravatar.com/avatar/' +
+ '275876e34cf609db118f3d84b799a790?d=retro&s=200',
+ 'email': False,
}
def test_trying_to_retrieve_single_non_existing(test_ctx):
diff --git a/server/szurubooru/tests/api/test_user_updating.py b/server/szurubooru/tests/api/test_user_updating.py
index 3696ce9..1e8cafa 100644
--- a/server/szurubooru/tests/api/test_user_updating.py
+++ b/server/szurubooru/tests/api/test_user_updating.py
@@ -49,16 +49,14 @@ def test_updating_user(test_ctx):
user=user),
'u1')
assert result == {
- 'user': {
- 'avatarStyle': 'gravatar',
- 'avatarUrl': 'http://gravatar.com/avatar/' +
- '6f370c8c7109534c3d5c394123a477d7?d=retro&s=200',
- 'creationTime': datetime.datetime(1997, 1, 1),
- 'lastLoginTime': None,
- 'email': 'asd@asd.asd',
- 'name': 'chewie',
- 'rank': 'moderator',
- }
+ 'avatarStyle': 'gravatar',
+ 'avatarUrl': 'http://gravatar.com/avatar/' +
+ '6f370c8c7109534c3d5c394123a477d7?d=retro&s=200',
+ 'creationTime': datetime.datetime(1997, 1, 1),
+ 'lastLoginTime': None,
+ 'email': 'asd@asd.asd',
+ 'name': 'chewie',
+ 'rank': 'moderator',
}
user = users.get_user_by_name('chewie')
assert user.name == 'chewie'
@@ -201,5 +199,5 @@ def test_uploading_avatar(test_ctx, tmpdir):
'u1')
user = users.get_user_by_name('u1')
assert user.avatar_style == user.AVATAR_MANUAL
- assert response['user']['avatarUrl'] == \
+ assert response['avatarUrl'] == \
'http://example.com/data/avatars/u1.png'