test(association): revois la vue détails avec le bouton Rejoindre

pull/105/head
Jérôme Lebleu 2019-09-12 16:50:30 +02:00
Parent 1e7db19fba
révision b4a1b7c3a0
1 fichiers modifiés avec 40 ajouts et 63 suppressions

Voir le fichier

@ -120,77 +120,54 @@ class TestAssosiationIndex:
@pytest.mark.django_db
class TestAssosiationDetail:
@pytest.mark.parametrize(
'use, expected',
[(None, 200), ('user', 200), ('staff', 200), ('foreign', 200)],
)
def test_access(
self, client, association, user, superuser, foreign, use, expected
):
if use == 'staff':
client.force_login(superuser)
elif use == 'foreign':
client.force_login(foreign)
elif use:
client.force_login(user)
response = client.get(
reverse('association:detail', args=[association.id])
@classmethod
@pytest.fixture(autouse=True)
def setup_class(cls, association):
cls.association = association
cls.url = reverse(
'association:detail', args=[cls.association.id]
)
assert response.status_code == expected
def test_get(self, client, user):
response = client.get(self.url)
assert response.status_code == 200
assert count_text_in_content(response, "association loi de 1901")
assert count_text_in_content(response, "Connectez-vous")
assert not count_text_in_content(response, "Rejoindre")
@pytest.mark.parametrize(
'use, expected',
[(None, 404), ('user', 404), ('staff', 200), ('foreign', 404)],
)
def test_access_conceal(
self, client, association, user, superuser, foreign, use, expected
):
association.conceal = True
association.save()
client.force_login(user)
response = client.get(self.url)
assert response.status_code == 200
assert count_text_in_content(response, "Rejoindre")
if use == 'staff':
client.force_login(superuser)
elif use == 'foreign':
client.force_login(foreign)
elif use:
client.force_login(user)
def test_get_with_engagement(self, client, user, engagement):
client.force_login(user)
response = client.get(self.url)
assert response.status_code == 200
assert not count_text_in_content(response, "Rejoindre")
response = client.get(
reverse('association:detail', args=[association.id])
)
assert response.status_code == expected
def test_get_conceal(self, client, user, superuser):
self.association.conceal = True
self.association.save()
@pytest.mark.parametrize(
'use, expected',
[(None, 404), ('user', 200), ('staff', 200), ('foreign', 404)],
)
def test_access_conceal_with_engagement(
self,
client,
association,
engagement,
user,
superuser,
foreign,
use,
expected,
):
association.conceal = True
association.save()
response = client.get(self.url)
assert response.status_code == 404
if use == 'staff':
client.force_login(superuser)
elif use == 'foreign':
client.force_login(foreign)
elif use:
client.force_login(user)
client.force_login(user)
response = client.get(self.url)
assert response.status_code == 404
response = client.get(
reverse('association:detail', args=[association.id])
)
assert response.status_code == expected
client.force_login(superuser)
response = client.get(self.url)
assert response.status_code == 200
def test_get_conceal_with_engagement(self, client, user, engagement):
self.association.conceal = True
self.association.save()
client.force_login(user)
response = client.get(self.url)
assert response.status_code == 200
def test_titlebuttons_foreign(self, client, association, foreign):
client.force_login(foreign)