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
|
import pytest
|
||||||
from servala.core.models import Organization, OrganizationMembership, User, OrganizationOrigin
|
|
||||||
|
|
||||||
|
from servala.core.models import (
|
||||||
|
Organization,
|
||||||
|
OrganizationMembership,
|
||||||
|
OrganizationOrigin,
|
||||||
|
User,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def origin():
|
def origin():
|
||||||
return OrganizationOrigin.objects.create(name="TESTORIGIN")
|
return OrganizationOrigin.objects.create(name="TESTORIGIN")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def organization(origin):
|
def organization(origin):
|
||||||
return Organization.objects.create(name="Test Org", origin=origin)
|
return Organization.objects.create(name="Test Org", origin=origin)
|
||||||
|
@ -16,9 +22,11 @@ def organization(origin):
|
||||||
def other_organization(origin):
|
def other_organization(origin):
|
||||||
return Organization.objects.create(name="Test Org Alternate", origin=origin)
|
return Organization.objects.create(name="Test Org Alternate", origin=origin)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def org_owner(organization):
|
def org_owner(organization):
|
||||||
user = User.objects.create(email="user@example.org", password="example")
|
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
|
return user
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("url,redirect", (
|
@pytest.mark.parametrize(
|
||||||
("/", "/accounts/login/?next=/"),
|
"url,redirect",
|
||||||
("/accounts/profile/", "/accounts/login/?next=/accounts/profile/")
|
(
|
||||||
))
|
("/", "/accounts/login/?next=/"),
|
||||||
|
("/accounts/profile/", "/accounts/login/?next=/accounts/profile/"),
|
||||||
|
),
|
||||||
|
)
|
||||||
def test_root_view_redirects_valid_urls(client, url, redirect):
|
def test_root_view_redirects_valid_urls(client, url, redirect):
|
||||||
response = client.get(url)
|
response = client.get(url)
|
||||||
assert response.status_code == 302
|
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
|
@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)
|
client.force_login(org_owner)
|
||||||
response = client.get("/", follow=True)
|
response = client.get("/", follow=True)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue