Blocklist: Fix already existing tests following modifications for blocklist
This commit is contained in:
parent
82721c0bcb
commit
9bb11158a3
5 changed files with 16 additions and 2 deletions
|
@ -26,6 +26,8 @@ def test_info_api(
|
|||
"tag_name_regex": "3",
|
||||
"tag_category_name_regex": "4",
|
||||
"default_rank": "5",
|
||||
"default_tag_blocklist": "testTag",
|
||||
"default_tag_blocklist_for_anonymous": True,
|
||||
"privileges": {
|
||||
"test_key1": "test_value1",
|
||||
"test_key2": "test_value2",
|
||||
|
@ -48,6 +50,8 @@ def test_info_api(
|
|||
"tagNameRegex": "3",
|
||||
"tagCategoryNameRegex": "4",
|
||||
"defaultUserRank": "5",
|
||||
"defaultTagBlocklist": "testTag",
|
||||
"defaultTagBlocklistForAnonymous": True,
|
||||
"privileges": {
|
||||
"testKey1": "test_value1",
|
||||
"testKey2": "test_value2",
|
||||
|
|
|
@ -21,6 +21,8 @@ def test_creating_user(user_factory, context_factory, fake_datetime):
|
|||
"szurubooru.func.users.update_user_rank"
|
||||
), patch(
|
||||
"szurubooru.func.users.update_user_avatar"
|
||||
), patch(
|
||||
"szurubooru.func.users.update_user_blocklist"
|
||||
), patch(
|
||||
"szurubooru.func.users.serialize_user"
|
||||
), fake_datetime(
|
||||
|
@ -28,6 +30,7 @@ def test_creating_user(user_factory, context_factory, fake_datetime):
|
|||
):
|
||||
users.serialize_user.return_value = "serialized user"
|
||||
users.create_user.return_value = user
|
||||
users.update_user_blocklist.return_value = ([],[])
|
||||
result = api.user_api.create_user(
|
||||
context_factory(
|
||||
params={
|
||||
|
@ -50,6 +53,7 @@ def test_creating_user(user_factory, context_factory, fake_datetime):
|
|||
assert not users.update_user_email.called
|
||||
users.update_user_rank.called_once_with(user, "moderator")
|
||||
users.update_user_avatar.called_once_with(user, "manual", b"...")
|
||||
users.update_user_blocklist.called_once_with(user, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", ["name", "password"])
|
||||
|
|
|
@ -14,11 +14,13 @@ def inject_config(config_injector):
|
|||
"users:edit:self:name": model.User.RANK_REGULAR,
|
||||
"users:edit:self:pass": model.User.RANK_REGULAR,
|
||||
"users:edit:self:email": model.User.RANK_REGULAR,
|
||||
"users:edit:self:blocklist": model.User.RANK_REGULAR,
|
||||
"users:edit:self:rank": model.User.RANK_MODERATOR,
|
||||
"users:edit:self:avatar": model.User.RANK_MODERATOR,
|
||||
"users:edit:any:name": model.User.RANK_MODERATOR,
|
||||
"users:edit:any:pass": model.User.RANK_MODERATOR,
|
||||
"users:edit:any:email": model.User.RANK_MODERATOR,
|
||||
"users:edit:any:blocklist": model.User.RANK_MODERATOR,
|
||||
"users:edit:any:rank": model.User.RANK_ADMINISTRATOR,
|
||||
"users:edit:any:avatar": model.User.RANK_ADMINISTRATOR,
|
||||
},
|
||||
|
|
|
@ -172,6 +172,7 @@ def post_factory():
|
|||
id=None,
|
||||
safety=model.Post.SAFETY_SAFE,
|
||||
type=model.Post.TYPE_IMAGE,
|
||||
tags=[],
|
||||
checksum="...",
|
||||
):
|
||||
post = model.Post()
|
||||
|
@ -182,6 +183,7 @@ def post_factory():
|
|||
post.flags = []
|
||||
post.mime_type = "application/octet-stream"
|
||||
post.creation_time = datetime(1996, 1, 1)
|
||||
post.tags = tags
|
||||
return post
|
||||
|
||||
return factory
|
||||
|
|
|
@ -158,6 +158,7 @@ def test_serialize_user(user_factory):
|
|||
"avatarUrl": "https://example.com/avatar.png",
|
||||
"likedPostCount": 66,
|
||||
"dislikedPostCount": 33,
|
||||
"blocklist": [],
|
||||
"commentCount": 0,
|
||||
"favoritePostCount": 0,
|
||||
"uploadedPostCount": 0,
|
||||
|
@ -235,7 +236,7 @@ def test_create_user_for_first_user(fake_datetime):
|
|||
"szurubooru.func.users.update_user_password"
|
||||
), patch("szurubooru.func.users.update_user_email"), fake_datetime(
|
||||
"1997-01-01"
|
||||
):
|
||||
), patch("szurubooru.func.users.update_user_blocklist"):
|
||||
user = users.create_user("name", "password", "email")
|
||||
assert user.creation_time == datetime(1997, 1, 1)
|
||||
assert user.last_login_time is None
|
||||
|
@ -251,7 +252,8 @@ def test_create_user_for_subsequent_users(user_factory, config_injector):
|
|||
db.session.flush()
|
||||
with patch("szurubooru.func.users.update_user_name"), patch(
|
||||
"szurubooru.func.users.update_user_email"
|
||||
), patch("szurubooru.func.users.update_user_password"):
|
||||
), patch("szurubooru.func.users.update_user_password"
|
||||
), patch("szurubooru.func.users.update_user_blocklist"):
|
||||
user = users.create_user("name", "password", "email")
|
||||
assert user.rank == model.User.RANK_REGULAR
|
||||
|
||||
|
|
Loading…
Reference in a new issue