fix(tests): teste les vues pour AnonymousEngagement

user_anonymized
Antoine 2023-01-12 18:35:46 +01:00
Parent 63f3f01bff
révision 31d686a971
1 fichiers modifiés avec 51 ajouts et 0 suppressions

Voir le fichier

@ -852,6 +852,57 @@ class TestEngagement(ManagerOnlyViewMixin):
assert "a été supprimé" in messages[0]
@pytest.mark.django_db
class TestAnonymousEngagement(ManagerOnlyViewMixin):
title = "Liste des bénévoles anonymes"
@pytest.fixture(autouse=True)
def setup(self, association):
cls = type(self)
cls.association = association
cls.url = reverse(
'association:anonymous-engagement:index', args=[cls.association.id]
)
super().setup()
def test_can_create_update_delete_anonymous_engagement(
self, client, user, manager
):
client.force_login(user)
response = client.get(self.url)
assert response.status_code == 200
result = bs(response.content, 'html.parser').select(
'.table-buttons > a'
)
create_url = result[0]['href']
response = client.get(create_url)
assert response.status_code == 200
response = client.post(create_url, {}, follow=True)
assert response.status_code == 200
index_html = bs(response.content, 'html.parser')
results = index_html.select('.cruditor-table tbody tr')
assert len(results) == 1
# un autre !
response = client.post(create_url, {}, follow=True)
index_html = bs(response.content, 'html.parser')
results = index_html.select('.cruditor-table tbody tr')
assert len(results) == 2
# on en desactive un
link = index_html.select('a.update-link')[0]['href']
response = client.get(link)
assert response.status_code == 200
response = client.post(link, {'is_active': False}, follow=True)
index_html = bs(response.content, 'html.parser')
results = index_html.select('.cruditor-table tbody tr')
# ci-dessous: on a pas selectionné la bonne td
assert results[0].select('td')[5].html.string == '<span class="false">✘</span>'
@pytest.mark.django_db
class TestLevel(ManagerOnlyViewMixin):
title = "Liste des niveaux"