diff options
| author | Hunternif <hunternif@gmail.com> | 2025-02-16 01:59:39 +0000 |
|---|---|---|
| committer | Hunternif <hunternif@gmail.com> | 2025-02-16 01:59:39 +0000 |
| commit | 7e09f39cb9c6ad5ffb20411906c13aca74343617 (patch) | |
| tree | f7bf38ee177254cc78590d1e594afafedbf94111 /server | |
| parent | fb763ada0fb5027f29f003f7dc3261c6b87f30a7 (diff) | |
server: fix tests for unsafe posts
Diffstat (limited to 'server')
3 files changed, 20 insertions, 10 deletions
diff --git a/server/szurubooru/tests/api/test_post_retrieving.py b/server/szurubooru/tests/api/test_post_retrieving.py index a40ab0e..4daf11f 100644 --- a/server/szurubooru/tests/api/test_post_retrieving.py +++ b/server/szurubooru/tests/api/test_post_retrieving.py @@ -15,6 +15,7 @@ def inject_config(config_injector): "posts:list": model.User.RANK_REGULAR, "posts:view": model.User.RANK_REGULAR, "posts:view:unsafe": model.User.RANK_REGULAR, + "posts:list:unsafe": model.User.RANK_REGULAR, }, } ) diff --git a/server/szurubooru/tests/search/configs/test_post_search_config.py b/server/szurubooru/tests/search/configs/test_post_search_config.py index e726f31..299b2ed 100644 --- a/server/szurubooru/tests/search/configs/test_post_search_config.py +++ b/server/szurubooru/tests/search/configs/test_post_search_config.py @@ -60,7 +60,15 @@ def executor(): @pytest.fixture -def auth_executor(executor, user_factory): +def auth_executor(executor, user_factory, config_injector): + config_injector( + { + "privileges": { + "posts:list:unsafe": model.User.RANK_REGULAR, + } + } + ) + def wrapper(): auth_user = user_factory() db.session.add(auth_user) @@ -927,15 +935,7 @@ def test_filter_unsafe_without_privilege( auth_executor, verify_unpaged, post_factory, - config_injector, ): - config_injector( - { - "privileges": { - "posts:list:unsafe": model.User.RANK_REGULAR, - } - } - ) post1 = post_factory(id=1) post2 = post_factory(id=2, safety=model.Post.SAFETY_SKETCHY) post3 = post_factory(id=3, safety=model.Post.SAFETY_UNSAFE) diff --git a/server/szurubooru/tests/search/test_executor.py b/server/szurubooru/tests/search/test_executor.py index 4530bee..5c52f72 100644 --- a/server/szurubooru/tests/search/test_executor.py +++ b/server/szurubooru/tests/search/test_executor.py @@ -2,10 +2,19 @@ import unittest.mock import pytest -from szurubooru import search +from szurubooru import search, model from szurubooru.func import cache +@pytest.fixture(autouse=True) +def inject_config(config_injector): + config_injector( + { + "privileges": {"posts:list:unsafe": model.User.RANK_REGULAR}, + } + ) + + def test_retrieving_from_cache(): config = unittest.mock.MagicMock() with unittest.mock.patch("szurubooru.func.cache.has"), unittest.mock.patch( |