Skip to content

Commit

Permalink
Fix visibility tests
Browse files Browse the repository at this point in the history
- don't rely on internal ID, which might vary between installs
  • Loading branch information
ajparsons committed Dec 21, 2024
1 parent 9524add commit 2d16d55
Showing 1 changed file with 43 additions and 22 deletions.
65 changes: 43 additions & 22 deletions tests/test_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import pytest

from votes.consts import PermissionGroupSlug
from votes.models import UserPersonLink
from votes.models import Division, UserPersonLink

pytestmark = pytest.mark.django_db


@pytest.fixture
def division_id():
return Division.objects.get(key="pw-2016-12-13-109-commons").id


@pytest.fixture
def test_rep_user():
"""
Expand Down Expand Up @@ -64,69 +69,85 @@ def test_report_whip_power_user():
user.delete()


def test_whip_form_visible(client: Client):
response = client.get("/submit/whip/78288")
def test_whip_form_visible(client: Client, division_id: int):
response = client.get(f"/submit/whip/{division_id}")
assert response.status_code == 404


def test_whip_form_visible_superuser(client: Client, test_super_user: User):
def test_whip_form_visible_superuser(
client: Client, division_id: int, test_super_user: User
):
client.force_login(test_super_user)
response = client.get("/submit/whip/78288")
response = client.get(f"/submit/whip/{division_id}")
assert response.status_code == 200


def test_whip_form_visible_group(client: Client, test_report_whip_power_user: User):
def test_whip_form_visible_group(
client: Client, division_id: int, test_report_whip_power_user: User
):
client.force_login(test_report_whip_power_user)
response = client.get("/submit/whip/78288")
response = client.get(f"/submit/whip/{division_id}")
assert response.status_code == 200


def test_whip_form_visible_group_incorrect(
client: Client, test_has_annotation_power_user: User
client: Client, division_id: int, test_has_annotation_power_user: User
):
client.force_login(test_has_annotation_power_user)
response = client.get("/submit/whip/78288")
response = client.get(f"/submit/whip/{division_id}")
assert response.status_code == 404


def test_self_whip_visible(client: Client):
response = client.get("/submit/rep_whip/78288")
def test_self_whip_visible(
client: Client,
division_id: int,
):
response = client.get(f"/submit/rep_whip/{division_id}")
assert response.status_code == 404


def test_self_whip_visible_rep(client: Client, test_rep_user: User):
def test_self_whip_visible_rep(client: Client, division_id: int, test_rep_user: User):
client.force_login(test_rep_user)
response = client.get("/submit/rep_whip/78288")
response = client.get(f"/submit/rep_whip/{division_id}")
assert response.status_code == 200


def test_self_annotate_visible(client: Client):
def test_self_annotate_visible(client: Client, division_id: int):
response = client.get(f"/submit/rep_annotation/{division_id}")

response = client.get("/submit/rep_annotation/78288")
assert response.status_code == 404


def test_form_visible(client: Client):
response = client.get("/submit/division_annotation/78288")
def test_form_visible(
client: Client,
division_id: int,
):
response = client.get(f"/submit/division_annotation/{division_id}")
assert response.status_code == 404


def test_form_visible_superuser(client: Client, test_super_user: User):
def test_form_visible_superuser(
client: Client, division_id: int, test_super_user: User
):
client.force_login(test_super_user)
response = client.get("/submit/division_annotation/78288")
response = client.get(f"/submit/division_annotation/{division_id}")
assert response.status_code == 200


def test_form_visible_group_incorrect(
client: Client, test_report_whip_power_user: User
client: Client, division_id: int, test_report_whip_power_user: User
):
client.force_login(test_report_whip_power_user)
response = client.get("/submit/division_annotation/78288")
response = client.get(f"/submit/division_annotation/{division_id}")
assert response.status_code == 404


def test_form_visible_group(client: Client, test_has_annotation_power_user: User):
def test_form_visible_group(
client: Client, division_id: int, test_has_annotation_power_user: User
):
client.force_login(test_has_annotation_power_user)
response = client.get("/submit/division_annotation/78288")
response = client.get(f"/submit/division_annotation/{division_id}")
assert response.status_code == 200


Expand Down

0 comments on commit 2d16d55

Please sign in to comment.