mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server: fix tests for unsafe posts
This commit is contained in:
@ -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,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user