From 14a20e55f8c44ac78c3e59493a4540c4d6d95163 Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 10 May 2016 12:01:01 +0200 Subject: [PATCH] server/tests: fix leftover rank strings --- server/szurubooru/tests/api/test_comment_creating.py | 2 +- server/szurubooru/tests/api/test_comment_rating.py | 2 +- server/szurubooru/tests/api/test_comment_retrieving.py | 4 ++-- server/szurubooru/tests/api/test_post_creating.py | 4 +--- server/szurubooru/tests/api/test_post_deleting.py | 2 +- server/szurubooru/tests/api/test_post_favoriting.py | 2 +- server/szurubooru/tests/api/test_post_featuring.py | 4 ++-- server/szurubooru/tests/api/test_post_rating.py | 2 +- server/szurubooru/tests/api/test_post_retrieving.py | 7 +++---- server/szurubooru/tests/api/test_post_updating.py | 5 +---- server/szurubooru/tests/api/test_snapshot_retrieving.py | 2 +- server/szurubooru/tests/api/test_tag_category_creating.py | 2 +- server/szurubooru/tests/api/test_tag_category_deleting.py | 2 +- .../szurubooru/tests/api/test_tag_category_retrieving.py | 2 +- server/szurubooru/tests/api/test_tag_category_updating.py | 2 +- server/szurubooru/tests/api/test_tag_creating.py | 2 +- server/szurubooru/tests/api/test_tag_deleting.py | 2 +- server/szurubooru/tests/api/test_tag_merging.py | 2 +- server/szurubooru/tests/api/test_tag_retrieving.py | 4 ++-- .../szurubooru/tests/api/test_tag_siblings_retrieving.py | 2 +- server/szurubooru/tests/api/test_tag_updating.py | 2 +- server/szurubooru/tests/api/test_user_creating.py | 6 +++--- server/szurubooru/tests/api/test_user_retrieving.py | 4 ++-- server/szurubooru/tests/api/test_user_updating.py | 8 ++++---- 24 files changed, 35 insertions(+), 41 deletions(-) diff --git a/server/szurubooru/tests/api/test_comment_creating.py b/server/szurubooru/tests/api/test_comment_creating.py index c38e0e4..1618014 100644 --- a/server/szurubooru/tests/api/test_comment_creating.py +++ b/server/szurubooru/tests/api/test_comment_creating.py @@ -87,4 +87,4 @@ def test_trying_to_create_without_privileges(test_ctx): test_ctx.api.post( test_ctx.context_factory( input={}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_comment_rating.py b/server/szurubooru/tests/api/test_comment_rating.py index 41c4afc..2632dc0 100644 --- a/server/szurubooru/tests/api/test_comment_rating.py +++ b/server/szurubooru/tests/api/test_comment_rating.py @@ -150,5 +150,5 @@ def test_trying_to_rate_without_privileges(test_ctx): test_ctx.api.put( test_ctx.context_factory( input={'score': 1}, - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), comment.comment_id) diff --git a/server/szurubooru/tests/api/test_comment_retrieving.py b/server/szurubooru/tests/api/test_comment_retrieving.py index 2161e3c..3d05696 100644 --- a/server/szurubooru/tests/api/test_comment_retrieving.py +++ b/server/szurubooru/tests/api/test_comment_retrieving.py @@ -43,7 +43,7 @@ def test_trying_to_retrieve_multiple_without_privileges(test_ctx): test_ctx.list_api.get( test_ctx.context_factory( input={'query': '', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) def test_retrieving_single(test_ctx): comment = test_ctx.comment_factory(text='dummy text') @@ -74,5 +74,5 @@ def test_trying_to_retrieve_single_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.detail_api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 5) diff --git a/server/szurubooru/tests/api/test_post_creating.py b/server/szurubooru/tests/api/test_post_creating.py index 99984d5..7f1593f 100644 --- a/server/szurubooru/tests/api/test_post_creating.py +++ b/server/szurubooru/tests/api/test_post_creating.py @@ -118,7 +118,6 @@ def test_creating_from_url_saves_source( unittest.mock.patch('szurubooru.func.posts.create_post'), \ unittest.mock.patch('szurubooru.func.posts.update_post_source'): config_injector({ - 'ranks': ['anonymous', db.User.RANK_REGULAR], 'privileges': {'posts:create': db.User.RANK_REGULAR}, }) net.download.return_value = b'content' @@ -150,7 +149,6 @@ def test_creating_from_url_with_source_specified( unittest.mock.patch('szurubooru.func.posts.create_post'), \ unittest.mock.patch('szurubooru.func.posts.update_post_source'): config_injector({ - 'ranks': ['anonymous', db.User.RANK_REGULAR], 'privileges': {'posts:create': db.User.RANK_REGULAR}, }) net.download.return_value = b'content' @@ -198,4 +196,4 @@ def test_trying_to_create_without_privileges(context_factory, user_factory): api.PostListApi().post( context_factory( input='whatever', - user=user_factory(rank='anonymous'))) + user=user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_post_deleting.py b/server/szurubooru/tests/api/test_post_deleting.py index a56be38..06cad18 100644 --- a/server/szurubooru/tests/api/test_post_deleting.py +++ b/server/szurubooru/tests/api/test_post_deleting.py @@ -43,6 +43,6 @@ def test_trying_to_delete_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.api.delete( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 1) assert db.session.query(db.Post).count() == 1 diff --git a/server/szurubooru/tests/api/test_post_favoriting.py b/server/szurubooru/tests/api/test_post_favoriting.py index 8485679..f4e0aa0 100644 --- a/server/szurubooru/tests/api/test_post_favoriting.py +++ b/server/szurubooru/tests/api/test_post_favoriting.py @@ -124,5 +124,5 @@ def test_trying_to_rate_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.api.post( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), post.post_id) diff --git a/server/szurubooru/tests/api/test_post_featuring.py b/server/szurubooru/tests/api/test_post_featuring.py index 258d665..ecd145f 100644 --- a/server/szurubooru/tests/api/test_post_featuring.py +++ b/server/szurubooru/tests/api/test_post_featuring.py @@ -98,12 +98,12 @@ def test_trying_to_feature_without_privileges(test_ctx): test_ctx.api.post( test_ctx.context_factory( input={'id': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) def test_getting_featured_post_without_privileges_to_view(test_ctx): try: test_ctx.api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) except: pytest.fail() diff --git a/server/szurubooru/tests/api/test_post_rating.py b/server/szurubooru/tests/api/test_post_rating.py index ed59b97..b8c9cb2 100644 --- a/server/szurubooru/tests/api/test_post_rating.py +++ b/server/szurubooru/tests/api/test_post_rating.py @@ -144,5 +144,5 @@ def test_trying_to_rate_without_privileges(test_ctx): test_ctx.api.put( test_ctx.context_factory( input={'score': 1}, - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), post.post_id) diff --git a/server/szurubooru/tests/api/test_post_retrieving.py b/server/szurubooru/tests/api/test_post_retrieving.py index 78aa871..deda634 100644 --- a/server/szurubooru/tests/api/test_post_retrieving.py +++ b/server/szurubooru/tests/api/test_post_retrieving.py @@ -60,20 +60,19 @@ def test_trying_to_use_special_tokens_without_logging_in( test_ctx, config_injector): config_injector({ 'privileges': {'posts:list': 'anonymous'}, - 'ranks': ['anonymous'], }) with pytest.raises(errors.SearchError): test_ctx.list_api.get( test_ctx.context_factory( input={'query': 'special:fav', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) def test_trying_to_retrieve_multiple_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.list_api.get( test_ctx.context_factory( input={'query': '', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) def test_retrieving_single(test_ctx): db.session.add(test_ctx.post_factory(id=1)) @@ -96,5 +95,5 @@ def test_trying_to_retrieve_single_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.detail_api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), '-') diff --git a/server/szurubooru/tests/api/test_post_updating.py b/server/szurubooru/tests/api/test_post_updating.py index 9163bf0..25b2b6b 100644 --- a/server/szurubooru/tests/api/test_post_updating.py +++ b/server/szurubooru/tests/api/test_post_updating.py @@ -75,7 +75,6 @@ def test_post_updating( def test_uploading_from_url_saves_source( config_injector, context_factory, post_factory, user_factory): config_injector({ - 'ranks': ['anonymous', db.User.RANK_REGULAR], 'privileges': {'posts:edit:content': db.User.RANK_REGULAR}, }) post = post_factory() @@ -100,7 +99,6 @@ def test_uploading_from_url_saves_source( def test_uploading_from_url_with_source_specified( config_injector, context_factory, post_factory, user_factory): config_injector({ - 'ranks': ['anonymous', db.User.RANK_REGULAR], 'privileges': { 'posts:edit:content': db.User.RANK_REGULAR, 'posts:edit:source': db.User.RANK_REGULAR, @@ -152,7 +150,6 @@ def test_trying_to_create_without_privileges( input, privilege): config_injector({ - 'ranks': ['anonymous', db.User.RANK_REGULAR], 'privileges': {privilege: db.User.RANK_REGULAR}, }) post = post_factory() @@ -163,5 +160,5 @@ def test_trying_to_create_without_privileges( context_factory( input=input, files=files, - user=user_factory(rank='anonymous')), + user=user_factory(rank=db.User.RANK_ANONYMOUS)), post.post_id) diff --git a/server/szurubooru/tests/api/test_snapshot_retrieving.py b/server/szurubooru/tests/api/test_snapshot_retrieving.py index 186bb23..aeeb829 100644 --- a/server/szurubooru/tests/api/test_snapshot_retrieving.py +++ b/server/szurubooru/tests/api/test_snapshot_retrieving.py @@ -46,4 +46,4 @@ def test_trying_to_retrieve_multiple_without_privileges(test_ctx): test_ctx.api.get( test_ctx.context_factory( input={'query': '', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_tag_category_creating.py b/server/szurubooru/tests/api/test_tag_category_creating.py index 62fe250..ba51aa1 100644 --- a/server/szurubooru/tests/api/test_tag_category_creating.py +++ b/server/szurubooru/tests/api/test_tag_category_creating.py @@ -88,4 +88,4 @@ def test_trying_to_create_without_privileges(test_ctx): test_ctx.api.post( test_ctx.context_factory( input={'name': 'meta', 'color': 'black'}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_tag_category_deleting.py b/server/szurubooru/tests/api/test_tag_category_deleting.py index 6f6de93..a9e04f4 100644 --- a/server/szurubooru/tests/api/test_tag_category_deleting.py +++ b/server/szurubooru/tests/api/test_tag_category_deleting.py @@ -74,6 +74,6 @@ def test_trying_to_delete_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.api.delete( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 'category') assert db.session.query(db.TagCategory).count() == 1 diff --git a/server/szurubooru/tests/api/test_tag_category_retrieving.py b/server/szurubooru/tests/api/test_tag_category_retrieving.py index 6c22dbe..e4f6651 100644 --- a/server/szurubooru/tests/api/test_tag_category_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_category_retrieving.py @@ -57,5 +57,5 @@ def test_trying_to_retrieve_single_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.detail_api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), '-') diff --git a/server/szurubooru/tests/api/test_tag_category_updating.py b/server/szurubooru/tests/api/test_tag_category_updating.py index ee182c4..fad6268 100644 --- a/server/szurubooru/tests/api/test_tag_category_updating.py +++ b/server/szurubooru/tests/api/test_tag_category_updating.py @@ -128,5 +128,5 @@ def test_trying_to_update_without_privileges(test_ctx, input): test_ctx.api.put( test_ctx.context_factory( input=input, - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 'dummy') diff --git a/server/szurubooru/tests/api/test_tag_creating.py b/server/szurubooru/tests/api/test_tag_creating.py index e7da646..78f8d87 100644 --- a/server/szurubooru/tests/api/test_tag_creating.py +++ b/server/szurubooru/tests/api/test_tag_creating.py @@ -266,4 +266,4 @@ def test_trying_to_create_tag_without_privileges(test_ctx): 'suggestions': ['tag'], 'implications': [], }, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_tag_deleting.py b/server/szurubooru/tests/api/test_tag_deleting.py index d0a8bc8..634962f 100644 --- a/server/szurubooru/tests/api/test_tag_deleting.py +++ b/server/szurubooru/tests/api/test_tag_deleting.py @@ -56,6 +56,6 @@ def test_trying_to_delete_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.api.delete( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 'tag') assert db.session.query(db.Tag).count() == 1 diff --git a/server/szurubooru/tests/api/test_tag_merging.py b/server/szurubooru/tests/api/test_tag_merging.py index a79f65b..b16252f 100644 --- a/server/szurubooru/tests/api/test_tag_merging.py +++ b/server/szurubooru/tests/api/test_tag_merging.py @@ -158,4 +158,4 @@ def test_trying_to_merge_without_privileges(test_ctx, input): 'remove': 'source', 'merge-to': 'target', }, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) diff --git a/server/szurubooru/tests/api/test_tag_retrieving.py b/server/szurubooru/tests/api/test_tag_retrieving.py index 9da35fb..98e7ee8 100644 --- a/server/szurubooru/tests/api/test_tag_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_retrieving.py @@ -39,7 +39,7 @@ def test_trying_to_retrieve_multiple_without_privileges(test_ctx): test_ctx.list_api.get( test_ctx.context_factory( input={'query': '', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + 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'])) @@ -71,5 +71,5 @@ def test_trying_to_retrieve_single_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.detail_api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), '-') diff --git a/server/szurubooru/tests/api/test_tag_siblings_retrieving.py b/server/szurubooru/tests/api/test_tag_siblings_retrieving.py index 418cf70..9f1af9d 100644 --- a/server/szurubooru/tests/api/test_tag_siblings_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_siblings_retrieving.py @@ -92,4 +92,4 @@ def test_trying_to_retrieve_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), '-') + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), '-') diff --git a/server/szurubooru/tests/api/test_tag_updating.py b/server/szurubooru/tests/api/test_tag_updating.py index 888ef85..cde09ff 100644 --- a/server/szurubooru/tests/api/test_tag_updating.py +++ b/server/szurubooru/tests/api/test_tag_updating.py @@ -259,5 +259,5 @@ def test_trying_to_update_without_privileges(test_ctx, input): test_ctx.api.put( test_ctx.context_factory( input=input, - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), 'tag') diff --git a/server/szurubooru/tests/api/test_user_creating.py b/server/szurubooru/tests/api/test_user_creating.py index 64419a6..127c612 100644 --- a/server/szurubooru/tests/api/test_user_creating.py +++ b/server/szurubooru/tests/api/test_user_creating.py @@ -61,7 +61,7 @@ def test_first_user_becomes_admin_others_not(test_ctx): 'email': 'asd@asd.asd', 'password': 'oks', }, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) result2 = test_ctx.api.post( test_ctx.context_factory( input={ @@ -69,7 +69,7 @@ def test_first_user_becomes_admin_others_not(test_ctx): 'email': 'asd@asd.asd', 'password': 'sok', }, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) assert result1['user']['rank'] == 'administrator' assert result2['user']['rank'] == 'regular' first_user = users.get_user_by_name('chewie1') @@ -86,7 +86,7 @@ def test_first_user_does_not_become_admin_if_they_dont_wish_so(test_ctx): 'password': 'oks', 'rank': 'regular', }, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) assert result['user']['rank'] == 'regular' def test_trying_to_become_someone_else(test_ctx): diff --git a/server/szurubooru/tests/api/test_user_retrieving.py b/server/szurubooru/tests/api/test_user_retrieving.py index eb8cd28..707f170 100644 --- a/server/szurubooru/tests/api/test_user_retrieving.py +++ b/server/szurubooru/tests/api/test_user_retrieving.py @@ -39,7 +39,7 @@ def test_trying_to_retrieve_multiple_without_privileges(test_ctx): test_ctx.list_api.get( test_ctx.context_factory( input={'query': '', 'page': 1}, - user=test_ctx.user_factory(rank='anonymous'))) + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS))) def test_retrieving_single(test_ctx): db.session.add(test_ctx.user_factory(name='u1', rank=db.User.RANK_REGULAR)) @@ -70,5 +70,5 @@ def test_trying_to_retrieve_single_without_privileges(test_ctx): with pytest.raises(errors.AuthError): test_ctx.detail_api.get( test_ctx.context_factory( - user=test_ctx.user_factory(rank='anonymous')), + user=test_ctx.user_factory(rank=db.User.RANK_ANONYMOUS)), '-') diff --git a/server/szurubooru/tests/api/test_user_updating.py b/server/szurubooru/tests/api/test_user_updating.py index f11e755..3696ce9 100644 --- a/server/szurubooru/tests/api/test_user_updating.py +++ b/server/szurubooru/tests/api/test_user_updating.py @@ -89,7 +89,7 @@ def test_updating_user(test_ctx): ({'avatarStyle': 'manual'}, users.InvalidAvatarError), # missing file ]) def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception): - user = test_ctx.user_factory(name='u1', rank='administrator') + user = test_ctx.user_factory(name='u1', rank=db.User.RANK_ADMINISTRATOR) db.session.add(user) with pytest.raises(expected_exception): test_ctx.api.put( @@ -100,7 +100,7 @@ def test_trying_to_pass_invalid_input(test_ctx, input, expected_exception): def test_omitting_optional_field(test_ctx, tmpdir, field): config.config['data_dir'] = str(tmpdir.mkdir('data')) config.config['data_url'] = 'http://example.com/data/' - user = test_ctx.user_factory(name='u1', rank='administrator') + user = test_ctx.user_factory(name='u1', rank=db.User.RANK_ADMINISTRATOR) db.session.add(user) input = { 'name': 'chewie', @@ -119,13 +119,13 @@ def test_omitting_optional_field(test_ctx, tmpdir, field): assert result is not None def test_trying_to_update_non_existing(test_ctx): - user = test_ctx.user_factory(name='u1', rank='administrator') + user = test_ctx.user_factory(name='u1', rank=db.User.RANK_ADMINISTRATOR) db.session.add(user) with pytest.raises(users.UserNotFoundError): test_ctx.api.put(test_ctx.context_factory(user=user), 'u2') def test_removing_email(test_ctx): - user = test_ctx.user_factory(name='u1', rank='administrator') + user = test_ctx.user_factory(name='u1', rank=db.User.RANK_ADMINISTRATOR) db.session.add(user) test_ctx.api.put( test_ctx.context_factory(input={'email': ''}, user=user), 'u1')