Code style
This commit is contained in:
parent
e85f1fc5f4
commit
a3d709aa3c
2 changed files with 21 additions and 8 deletions
|
@ -1,12 +1,18 @@
|
|||
import pytest
|
||||
from servala.core.models import Organization, OrganizationMembership, User, OrganizationOrigin
|
||||
|
||||
from servala.core.models import (
|
||||
Organization,
|
||||
OrganizationMembership,
|
||||
OrganizationOrigin,
|
||||
User,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def origin():
|
||||
return OrganizationOrigin.objects.create(name="TESTORIGIN")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organization(origin):
|
||||
return Organization.objects.create(name="Test Org", origin=origin)
|
||||
|
@ -16,9 +22,11 @@ def organization(origin):
|
|||
def other_organization(origin):
|
||||
return Organization.objects.create(name="Test Org Alternate", origin=origin)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def org_owner(organization):
|
||||
user = User.objects.create(email="user@example.org", password="example")
|
||||
OrganizationMembership.objects.create(organization=organization, user=user, role="owner")
|
||||
OrganizationMembership.objects.create(
|
||||
organization=organization, user=user, role="owner"
|
||||
)
|
||||
return user
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url,redirect", (
|
||||
("/", "/accounts/login/?next=/"),
|
||||
("/accounts/profile/", "/accounts/login/?next=/accounts/profile/")
|
||||
))
|
||||
@pytest.mark.parametrize(
|
||||
"url,redirect",
|
||||
(
|
||||
("/", "/accounts/login/?next=/"),
|
||||
("/accounts/profile/", "/accounts/login/?next=/accounts/profile/"),
|
||||
),
|
||||
)
|
||||
def test_root_view_redirects_valid_urls(client, url, redirect):
|
||||
response = client.get(url)
|
||||
assert response.status_code == 302
|
||||
|
@ -33,7 +36,9 @@ def test_user_cannot_see_other_organization(client, org_owner, other_organizatio
|
|||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organization_linked_in_sidebar(client, org_owner, organization, other_organization):
|
||||
def test_organization_linked_in_sidebar(
|
||||
client, org_owner, organization, other_organization
|
||||
):
|
||||
client.force_login(org_owner)
|
||||
response = client.get("/", follow=True)
|
||||
assert response.status_code == 200
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue