test(ui): attrape les boutons supprimer par leur contenu
Parent
a13a449dad
révision
27f4fa974e
|
@ -9,6 +9,7 @@ from bs4 import BeautifulSoup as bs
|
|||
from benevalibre.association.models import Association
|
||||
from benevalibre.association.views import get_management_buttons
|
||||
from benevalibre.utils.tests import (
|
||||
RE_DELETE_BTN,
|
||||
ManagerOnlyViewMixin,
|
||||
count_text_in_content,
|
||||
is_login_view,
|
||||
|
@ -333,7 +334,7 @@ class TestAssociationCreate:
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -560,7 +561,7 @@ class TestProjet(ManagerOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -776,7 +777,7 @@ class TestLevel(ManagerOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -863,7 +864,7 @@ class TestRole(ManagerOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -1007,7 +1008,7 @@ class TestCategory(ManagerOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
|
|
@ -7,7 +7,11 @@ import pytest
|
|||
from bs4 import BeautifulSoup as bs
|
||||
|
||||
from benevalibre.association.models import Association
|
||||
from benevalibre.utils.tests import count_text_in_content, is_login_view
|
||||
from benevalibre.utils.tests import (
|
||||
RE_DELETE_BTN,
|
||||
count_text_in_content,
|
||||
is_login_view,
|
||||
)
|
||||
|
||||
|
||||
class TestHome:
|
||||
|
@ -281,7 +285,7 @@ class TestBoard:
|
|||
# 5. On delete
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', string="Supprimer")
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -774,7 +778,7 @@ class TestBenevalo:
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
|
|
@ -8,7 +8,11 @@ from bs4 import BeautifulSoup as bs
|
|||
from reversion.models import Version
|
||||
|
||||
from benevalibre.benevalo.models import Benevalo
|
||||
from benevalibre.utils.tests import StaffOnlyViewMixin, count_text_in_content
|
||||
from benevalibre.utils.tests import (
|
||||
RE_DELETE_BTN,
|
||||
StaffOnlyViewMixin,
|
||||
count_text_in_content,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
@ -111,7 +115,7 @@ class TestBenevalo(StaffOnlyViewMixin):
|
|||
# 4. on delete
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
|
|
@ -4,7 +4,11 @@ from django.urls import reverse_lazy
|
|||
import pytest
|
||||
from bs4 import BeautifulSoup as bs
|
||||
|
||||
from benevalibre.utils.tests import StaffOnlyViewMixin, count_text_in_content
|
||||
from benevalibre.utils.tests import (
|
||||
RE_DELETE_BTN,
|
||||
StaffOnlyViewMixin,
|
||||
count_text_in_content,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
@ -51,7 +55,7 @@ class TestInstanceCategory(StaffOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -78,7 +82,7 @@ class TestInstanceCategory(StaffOnlyViewMixin):
|
|||
# 2. on poste la confirmation de deletion
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -132,7 +136,7 @@ class TestDefaultCategory(StaffOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -187,7 +191,7 @@ class TestDefaultRole(StaffOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
@ -242,7 +246,7 @@ class TestDefaultLevel(StaffOnlyViewMixin):
|
|||
response = client.get(url, follow=True)
|
||||
url = (
|
||||
bs(response.content, 'html.parser')
|
||||
.find('a', class_='btn-outline-danger')
|
||||
.find('a', string=RE_DELETE_BTN)
|
||||
.attrs['href']
|
||||
)
|
||||
data = {'confirm': True}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.test.html import parse_html
|
||||
|
||||
RE_DELETE_BTN = re.compile(r"^[\s]*Supprimer[\s]*$", re.MULTILINE)
|
||||
|
||||
|
||||
def parse_content(response, html=False):
|
||||
"""
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket