60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# type: ignore
|
|
from __future__ import annotations
|
|
|
|
from django.test import Client
|
|
from django.urls import reverse
|
|
import pytest
|
|
from pytest_django import asserts
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_ok(authenticated_client: Client):
|
|
# When
|
|
result = authenticated_client.get(
|
|
reverse('ui.associations.index'),
|
|
)
|
|
|
|
# Then
|
|
asserts.assertRedirects(
|
|
result,
|
|
reverse('ui.associations.browse'),
|
|
fetch_redirect_response=False,
|
|
)
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_inactive_account(inactive_account_client: Client):
|
|
# When
|
|
result = inactive_account_client.get(
|
|
reverse('ui.associations.index'),
|
|
)
|
|
|
|
# Then
|
|
asserts.assertRedirects(
|
|
result,
|
|
reverse(
|
|
'ui.accounts.login',
|
|
query=[('next', reverse('ui.associations.index'))],
|
|
),
|
|
fetch_redirect_response=False,
|
|
)
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_anonymous(client: Client):
|
|
# When
|
|
result = client.get(
|
|
reverse('ui.associations.index'),
|
|
)
|
|
|
|
# Then
|
|
asserts.assertRedirects(
|
|
result,
|
|
reverse(
|
|
'ui.accounts.login',
|
|
query=[('next', reverse('ui.associations.index'))],
|
|
),
|
|
fetch_redirect_response=False,
|
|
)
|