mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-12-22 22:01:48 +01:00
Validate notes access
This commit is contained in:
parent
00cdc6f19d
commit
50c66458fc
1 changed files with 27 additions and 5 deletions
|
@ -8,18 +8,20 @@ from party.models import Party
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_can_access_own_character(client):
|
||||
# Create a user
|
||||
player = User.objects.create_user("username", password="password")
|
||||
|
||||
character = baker.make(Character, player=player)
|
||||
notes = "Some notes"
|
||||
character = baker.make(Character, player=player, notes=notes)
|
||||
client.force_login(player)
|
||||
res = client.get(character.get_absolute_url())
|
||||
assert res.status_code == 200
|
||||
|
||||
body = res.content.decode("utf-8")
|
||||
assert notes in body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_cant_access_random_character(client):
|
||||
# Create a user
|
||||
player = User.objects.create_user("user", password="password")
|
||||
other = User.objects.create_user("other", password="password")
|
||||
|
||||
|
@ -31,15 +33,35 @@ def test_cant_access_random_character(client):
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_can_access_character_in_party(client):
|
||||
# Create a user
|
||||
player = User.objects.create_user("user", password="password")
|
||||
friend = User.objects.create_user("friend", password="password")
|
||||
|
||||
character = baker.make(Character, player=player)
|
||||
friend_character = baker.make(Character, player=friend)
|
||||
notes = "Some notes"
|
||||
friend_character = baker.make(Character, player=friend, notes=notes)
|
||||
party = baker.make(Party)
|
||||
party.characters.add(character)
|
||||
party.characters.add(friend_character)
|
||||
client.force_login(player)
|
||||
res = client.get(friend_character.get_absolute_url())
|
||||
assert res.status_code == 200
|
||||
|
||||
body = res.content.decode("utf-8")
|
||||
assert notes not in body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_game_master_can_access_character_in_party(client):
|
||||
player = User.objects.create_user("user", password="password")
|
||||
gm = User.objects.create_user("gm", password="password")
|
||||
|
||||
notes = "Some notes"
|
||||
character = baker.make(Character, player=player, notes=notes)
|
||||
party = baker.make(Party, game_master=gm)
|
||||
party.characters.add(character)
|
||||
client.force_login(gm)
|
||||
res = client.get(character.get_absolute_url())
|
||||
assert res.status_code == 200
|
||||
|
||||
body = res.content.decode("utf-8")
|
||||
assert notes in body
|
||||
|
|
Loading…
Reference in a new issue