diff options
| author | Shyam Sunder | 2020-09-01 14:06:22 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-09-01 14:07:39 -0400 |
| commit | 0dd427755b601da8dadf9af1a34ecad03f8446f9 (patch) | |
| tree | 7f7e072132a834f1ac64e973a4ef1fd8d5a46a94 /server/szurubooru/tests/api | |
| parent | 67a5dd7c18758304d42716383eb9497a143142b9 (diff) | |
client+server: fix linter issues due to updated pre-commit hooks
Diffstat (limited to 'server/szurubooru/tests/api')
21 files changed, 134 insertions, 33 deletions
diff --git a/server/szurubooru/tests/api/test_comment_creating.py b/server/szurubooru/tests/api/test_comment_creating.py index 3f9479b..b16ce65 100644 --- a/server/szurubooru/tests/api/test_comment_creating.py +++ b/server/szurubooru/tests/api/test_comment_creating.py @@ -40,7 +40,13 @@ def test_creating_comment( @pytest.mark.parametrize( - "params", [{"text": None}, {"text": ""}, {"text": [None]}, {"text": [""]},] + "params", + [ + {"text": None}, + {"text": ""}, + {"text": [None]}, + {"text": [""]}, + ], ) def test_trying_to_pass_invalid_params( user_factory, post_factory, context_factory, params diff --git a/server/szurubooru/tests/api/test_info.py b/server/szurubooru/tests/api/test_info.py index 57bf7a3..37099e8 100644 --- a/server/szurubooru/tests/api/test_info.py +++ b/server/szurubooru/tests/api/test_info.py @@ -31,7 +31,9 @@ def test_info_api( "test_key2": "test_value2", "posts:view:featured": "regular", }, - "smtp": {"host": "example.com",}, + "smtp": { + "host": "example.com", + }, } ) db.session.add_all([post_factory(), post_factory()]) diff --git a/server/szurubooru/tests/api/test_password_reset.py b/server/szurubooru/tests/api/test_password_reset.py index 28e4c12..bf1ab5c 100644 --- a/server/szurubooru/tests/api/test_password_reset.py +++ b/server/szurubooru/tests/api/test_password_reset.py @@ -13,7 +13,9 @@ def inject_config(config_injector): "secret": "x", "domain": "http://example.com", "name": "Test instance", - "smtp": {"from": "noreply@example.com",}, + "smtp": { + "from": "noreply@example.com", + }, } ) diff --git a/server/szurubooru/tests/api/test_pool_category_creating.py b/server/szurubooru/tests/api/test_pool_category_creating.py index c13c1ec..b9235d0 100644 --- a/server/szurubooru/tests/api/test_pool_category_creating.py +++ b/server/szurubooru/tests/api/test_pool_category_creating.py @@ -13,7 +13,9 @@ def _update_category_name(category, name): @pytest.fixture(autouse=True) def inject_config(config_injector): config_injector( - {"privileges": {"pool_categories:create": model.User.RANK_REGULAR},} + { + "privileges": {"pool_categories:create": model.User.RANK_REGULAR}, + } ) diff --git a/server/szurubooru/tests/api/test_pool_category_deleting.py b/server/szurubooru/tests/api/test_pool_category_deleting.py index cdbdcfe..b50f961 100644 --- a/server/szurubooru/tests/api/test_pool_category_deleting.py +++ b/server/szurubooru/tests/api/test_pool_category_deleting.py @@ -9,7 +9,9 @@ from szurubooru.func import pool_categories, snapshots @pytest.fixture(autouse=True) def inject_config(config_injector): config_injector( - {"privileges": {"pool_categories:delete": model.User.RANK_REGULAR},} + { + "privileges": {"pool_categories:delete": model.User.RANK_REGULAR}, + } ) diff --git a/server/szurubooru/tests/api/test_pool_category_retrieving.py b/server/szurubooru/tests/api/test_pool_category_retrieving.py index ea837c4..7820567 100644 --- a/server/szurubooru/tests/api/test_pool_category_retrieving.py +++ b/server/szurubooru/tests/api/test_pool_category_retrieving.py @@ -20,7 +20,10 @@ def test_retrieving_multiple( user_factory, pool_category_factory, context_factory ): db.session.add_all( - [pool_category_factory(name="c1"), pool_category_factory(name="c2"),] + [ + pool_category_factory(name="c1"), + pool_category_factory(name="c2"), + ] ) db.session.flush() result = api.pool_category_api.get_pool_categories( diff --git a/server/szurubooru/tests/api/test_pool_category_updating.py b/server/szurubooru/tests/api/test_pool_category_updating.py index c13112f..5e26209 100644 --- a/server/szurubooru/tests/api/test_pool_category_updating.py +++ b/server/szurubooru/tests/api/test_pool_category_updating.py @@ -89,7 +89,11 @@ def test_trying_to_update_non_existing(user_factory, context_factory): @pytest.mark.parametrize( - "params", [{"name": "whatever"}, {"color": "whatever"},] + "params", + [ + {"name": "whatever"}, + {"color": "whatever"}, + ], ) def test_trying_to_update_without_privileges( user_factory, pool_category_factory, context_factory, params @@ -119,7 +123,11 @@ def test_set_as_default(user_factory, pool_category_factory, context_factory): pool_categories.serialize_category.return_value = "serialized category" result = api.pool_category_api.set_pool_category_as_default( context_factory( - params={"name": "changed", "color": "white", "version": 1,}, + params={ + "name": "changed", + "color": "white", + "version": 1, + }, user=user_factory(rank=model.User.RANK_REGULAR), ), {"category_name": "name"}, diff --git a/server/szurubooru/tests/api/test_pool_merging.py b/server/szurubooru/tests/api/test_pool_merging.py index d0e5532..3357780 100644 --- a/server/szurubooru/tests/api/test_pool_merging.py +++ b/server/szurubooru/tests/api/test_pool_merging.py @@ -52,7 +52,10 @@ def test_trying_to_omit_mandatory_field( user_factory, pool_factory, context_factory, field ): db.session.add_all( - [pool_factory(id=1), pool_factory(id=2),] + [ + pool_factory(id=1), + pool_factory(id=2), + ] ) db.session.commit() params = { @@ -95,7 +98,10 @@ def test_trying_to_merge_without_privileges( user_factory, pool_factory, context_factory ): db.session.add_all( - [pool_factory(id=1), pool_factory(id=2),] + [ + pool_factory(id=1), + pool_factory(id=2), + ] ) db.session.commit() with pytest.raises(errors.AuthError): diff --git a/server/szurubooru/tests/api/test_pool_updating.py b/server/szurubooru/tests/api/test_pool_updating.py index aa2c09a..507289f 100644 --- a/server/szurubooru/tests/api/test_pool_updating.py +++ b/server/szurubooru/tests/api/test_pool_updating.py @@ -65,7 +65,13 @@ def test_simple_updating(user_factory, pool_factory, context_factory): @pytest.mark.parametrize( - "field", ["names", "category", "description", "posts",] + "field", + [ + "names", + "category", + "description", + "posts", + ], ) def test_omitting_optional_field( user_factory, pool_factory, context_factory, field @@ -106,7 +112,11 @@ def test_trying_to_update_non_existing(user_factory, context_factory): @pytest.mark.parametrize( "params", - [{"names": ["whatever"]}, {"category": "whatever"}, {"posts": [1]},], + [ + {"names": ["whatever"]}, + {"category": "whatever"}, + {"posts": [1]}, + ], ) def test_trying_to_update_without_privileges( user_factory, pool_factory, context_factory, params diff --git a/server/szurubooru/tests/api/test_post_creating.py b/server/szurubooru/tests/api/test_post_creating.py index e2db0eb..a1ad4de 100644 --- a/server/szurubooru/tests/api/test_post_creating.py +++ b/server/szurubooru/tests/api/test_post_creating.py @@ -47,7 +47,10 @@ def test_creating_minimal_posts(context_factory, post_factory, user_factory): result = api.post_api.create_post( context_factory( - params={"safety": "safe", "tags": ["tag1", "tag2"],}, + params={ + "safety": "safe", + "tags": ["tag1", "tag2"], + }, files={ "content": "post-content", "thumbnail": "post-thumbnail", @@ -109,7 +112,9 @@ def test_creating_full_posts(context_factory, post_factory, user_factory): "notes": ["note1", "note2"], "flags": ["flag1", "flag2"], }, - files={"content": "post-content",}, + files={ + "content": "post-content", + }, user=auth_user, ) ) @@ -162,7 +167,9 @@ def test_anonymous_uploads( "tags": ["tag1", "tag2"], "anonymous": "True", }, - files={"content": "post-content",}, + files={ + "content": "post-content", + }, user=auth_user, ) ) @@ -327,7 +334,10 @@ def test_errors_not_spending_ids( { "data_dir": str(tmpdir.mkdir("data")), "data_url": "example.com", - "thumbnails": {"post_width": 300, "post_height": 300,}, + "thumbnails": { + "post_width": 300, + "post_height": 300, + }, "privileges": { "posts:create:identified": model.User.RANK_REGULAR, "uploads:use_downloader": model.User.RANK_POWER, @@ -382,7 +392,10 @@ def test_trying_to_omit_content(context_factory, user_factory): with pytest.raises(errors.MissingRequiredFileError): api.post_api.create_post( context_factory( - params={"safety": "safe", "tags": ["tag1", "tag2"],}, + params={ + "safety": "safe", + "tags": ["tag1", "tag2"], + }, user=user_factory(rank=model.User.RANK_REGULAR), ) ) @@ -419,8 +432,13 @@ def test_trying_to_create_tags_without_privileges( posts.update_post_tags.return_value = ["new-tag"] api.post_api.create_post( context_factory( - params={"safety": "safe", "tags": ["tag1", "tag2"],}, - files={"content": posts.EMPTY_PIXEL,}, + params={ + "safety": "safe", + "tags": ["tag1", "tag2"], + }, + files={ + "content": posts.EMPTY_PIXEL, + }, user=user_factory(rank=model.User.RANK_REGULAR), ) ) diff --git a/server/szurubooru/tests/api/test_post_retrieving.py b/server/szurubooru/tests/api/test_post_retrieving.py index 8f2c371..ac984c2 100644 --- a/server/szurubooru/tests/api/test_post_retrieving.py +++ b/server/szurubooru/tests/api/test_post_retrieving.py @@ -72,7 +72,9 @@ def test_trying_to_use_special_tokens_without_logging_in( user_factory, context_factory, config_injector ): config_injector( - {"privileges": {"posts:list": "anonymous"},} + { + "privileges": {"posts:list": "anonymous"}, + } ) with pytest.raises(errors.SearchError): api.post_api.get_posts( diff --git a/server/szurubooru/tests/api/test_snapshot_retrieving.py b/server/szurubooru/tests/api/test_snapshot_retrieving.py index ec24e82..ea59d77 100644 --- a/server/szurubooru/tests/api/test_snapshot_retrieving.py +++ b/server/szurubooru/tests/api/test_snapshot_retrieving.py @@ -19,7 +19,9 @@ def snapshot_factory(): @pytest.fixture(autouse=True) def inject_config(config_injector): config_injector( - {"privileges": {"snapshots:list": model.User.RANK_REGULAR},} + { + "privileges": {"snapshots:list": model.User.RANK_REGULAR}, + } ) diff --git a/server/szurubooru/tests/api/test_tag_category_creating.py b/server/szurubooru/tests/api/test_tag_category_creating.py index 78f3068..2370cb8 100644 --- a/server/szurubooru/tests/api/test_tag_category_creating.py +++ b/server/szurubooru/tests/api/test_tag_category_creating.py @@ -13,7 +13,9 @@ def _update_category_name(category, name): @pytest.fixture(autouse=True) def inject_config(config_injector): config_injector( - {"privileges": {"tag_categories:create": model.User.RANK_REGULAR},} + { + "privileges": {"tag_categories:create": model.User.RANK_REGULAR}, + } ) diff --git a/server/szurubooru/tests/api/test_tag_category_deleting.py b/server/szurubooru/tests/api/test_tag_category_deleting.py index 2e6be64..23a3a42 100644 --- a/server/szurubooru/tests/api/test_tag_category_deleting.py +++ b/server/szurubooru/tests/api/test_tag_category_deleting.py @@ -9,7 +9,9 @@ from szurubooru.func import snapshots, tag_categories, tags @pytest.fixture(autouse=True) def inject_config(config_injector): config_injector( - {"privileges": {"tag_categories:delete": model.User.RANK_REGULAR},} + { + "privileges": {"tag_categories:delete": model.User.RANK_REGULAR}, + } ) diff --git a/server/szurubooru/tests/api/test_tag_category_retrieving.py b/server/szurubooru/tests/api/test_tag_category_retrieving.py index 9c2c6fb..40d9059 100644 --- a/server/szurubooru/tests/api/test_tag_category_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_category_retrieving.py @@ -20,7 +20,10 @@ def test_retrieving_multiple( user_factory, tag_category_factory, context_factory ): db.session.add_all( - [tag_category_factory(name="c1"), tag_category_factory(name="c2"),] + [ + tag_category_factory(name="c1"), + tag_category_factory(name="c2"), + ] ) db.session.flush() result = api.tag_category_api.get_tag_categories( diff --git a/server/szurubooru/tests/api/test_tag_category_updating.py b/server/szurubooru/tests/api/test_tag_category_updating.py index 6c32737..4134613 100644 --- a/server/szurubooru/tests/api/test_tag_category_updating.py +++ b/server/szurubooru/tests/api/test_tag_category_updating.py @@ -87,7 +87,11 @@ def test_trying_to_update_non_existing(user_factory, context_factory): @pytest.mark.parametrize( - "params", [{"name": "whatever"}, {"color": "whatever"},] + "params", + [ + {"name": "whatever"}, + {"color": "whatever"}, + ], ) def test_trying_to_update_without_privileges( user_factory, tag_category_factory, context_factory, params @@ -115,7 +119,11 @@ def test_set_as_default(user_factory, tag_category_factory, context_factory): tag_categories.serialize_category.return_value = "serialized category" result = api.tag_category_api.set_tag_category_as_default( context_factory( - params={"name": "changed", "color": "white", "version": 1,}, + params={ + "name": "changed", + "color": "white", + "version": 1, + }, user=user_factory(rank=model.User.RANK_REGULAR), ), {"category_name": "name"}, diff --git a/server/szurubooru/tests/api/test_tag_merging.py b/server/szurubooru/tests/api/test_tag_merging.py index be7e887..84c13d3 100644 --- a/server/szurubooru/tests/api/test_tag_merging.py +++ b/server/szurubooru/tests/api/test_tag_merging.py @@ -52,7 +52,10 @@ def test_trying_to_omit_mandatory_field( user_factory, tag_factory, context_factory, field ): db.session.add_all( - [tag_factory(names=["source"]), tag_factory(names=["target"]),] + [ + tag_factory(names=["source"]), + tag_factory(names=["target"]), + ] ) db.session.commit() params = { @@ -95,7 +98,10 @@ def test_trying_to_merge_without_privileges( user_factory, tag_factory, context_factory ): db.session.add_all( - [tag_factory(names=["source"]), tag_factory(names=["target"]),] + [ + tag_factory(names=["source"]), + tag_factory(names=["target"]), + ] ) db.session.commit() with pytest.raises(errors.AuthError): diff --git a/server/szurubooru/tests/api/test_tag_siblings_retrieving.py b/server/szurubooru/tests/api/test_tag_siblings_retrieving.py index 26f6666..7453b98 100644 --- a/server/szurubooru/tests/api/test_tag_siblings_retrieving.py +++ b/server/szurubooru/tests/api/test_tag_siblings_retrieving.py @@ -31,8 +31,14 @@ def test_get_tag_siblings(user_factory, tag_factory, context_factory): ) assert result == { "results": [ - {"tag": "serialized tag sib1", "occurrences": 1,}, - {"tag": "serialized tag sib2", "occurrences": 3,}, + { + "tag": "serialized tag sib1", + "occurrences": 1, + }, + { + "tag": "serialized tag sib2", + "occurrences": 3, + }, ], } diff --git a/server/szurubooru/tests/api/test_tag_updating.py b/server/szurubooru/tests/api/test_tag_updating.py index e2b0e00..729734d 100644 --- a/server/szurubooru/tests/api/test_tag_updating.py +++ b/server/szurubooru/tests/api/test_tag_updating.py @@ -75,7 +75,13 @@ def test_simple_updating(user_factory, tag_factory, context_factory): @pytest.mark.parametrize( "field", - ["names", "category", "description", "implications", "suggestions",], + [ + "names", + "category", + "description", + "implications", + "suggestions", + ], ) def test_omitting_optional_field( user_factory, tag_factory, context_factory, field diff --git a/server/szurubooru/tests/api/test_user_token_updating.py b/server/szurubooru/tests/api/test_user_token_updating.py index 6bc5e11..3f66041 100644 --- a/server/szurubooru/tests/api/test_user_token_updating.py +++ b/server/szurubooru/tests/api/test_user_token_updating.py @@ -29,7 +29,10 @@ def test_edit_user_token(user_token_factory, context_factory, fake_datetime): user_tokens.get_by_user_and_token.return_value = user_token result = api.user_token_api.update_user_token( context_factory( - params={"version": user_token.version, "enabled": False,}, + params={ + "version": user_token.version, + "enabled": False, + }, user=user_token.user, ), { diff --git a/server/szurubooru/tests/api/test_user_updating.py b/server/szurubooru/tests/api/test_user_updating.py index 08ccc78..304e489 100644 --- a/server/szurubooru/tests/api/test_user_updating.py +++ b/server/szurubooru/tests/api/test_user_updating.py @@ -55,7 +55,9 @@ def test_updating_user(context_factory, user_factory): "rank": "moderator", "avatarStyle": "manual", }, - files={"avatar": b"...",}, + files={ + "avatar": b"...", + }, user=auth_user, ), {"user_name": "u1"}, |