mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-26 05:05:17 +00:00
response.content.decode()
=> response.text
This commit is contained in:
parent
ad4afce67f
commit
805ffc498f
@ -34,7 +34,7 @@ class Command(BaseCommand):
|
|||||||
f"Source {provider} responded with code {res.status_code}"
|
f"Source {provider} responded with code {res.status_code}"
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
domains |= set(res.content.decode().splitlines())
|
domains |= set(res.text.splitlines())
|
||||||
return domains
|
return domains
|
||||||
|
|
||||||
def _update_domains(self, domains: set[str]):
|
def _update_domains(self, domains: set[str]):
|
||||||
|
@ -38,7 +38,7 @@ class TestMailingForm(TestCase):
|
|||||||
self.assertRedirects(response, self.mail_url)
|
self.assertRedirects(response, self.mail_url)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "Liste de diffusion foyer@utbm.fr" in response.content.decode()
|
assert "Liste de diffusion foyer@utbm.fr" in response.text
|
||||||
|
|
||||||
# Test with Root
|
# Test with Root
|
||||||
self.client.force_login(self.root)
|
self.client.force_login(self.root)
|
||||||
@ -48,7 +48,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "Liste de diffusion mde@utbm.fr" in response.content.decode()
|
assert "Liste de diffusion mde@utbm.fr" in response.text
|
||||||
|
|
||||||
def test_mailing_list_add_moderation(self):
|
def test_mailing_list_add_moderation(self):
|
||||||
self.client.force_login(self.rbatsbak)
|
self.client.force_login(self.rbatsbak)
|
||||||
@ -58,7 +58,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
assert "Liste de diffusion mde@utbm.fr" not in content
|
assert "Liste de diffusion mde@utbm.fr" not in content
|
||||||
assert "<p>Listes de diffusions en attente de modération</p>" in content
|
assert "<p>Listes de diffusions en attente de modération</p>" in content
|
||||||
assert "<li>mde@utbm.fr" in content
|
assert "<li>mde@utbm.fr" in content
|
||||||
@ -90,7 +90,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "skia@git.an" not in response.content.decode()
|
assert "skia@git.an" not in response.text
|
||||||
|
|
||||||
def test_add_new_subscription_success(self):
|
def test_add_new_subscription_success(self):
|
||||||
# Prepare mailing list
|
# Prepare mailing list
|
||||||
@ -111,7 +111,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "skia@git.an" in response.content.decode()
|
assert "skia@git.an" in response.text
|
||||||
|
|
||||||
# Add multiple users
|
# Add multiple users
|
||||||
self.client.post(
|
self.client.post(
|
||||||
@ -124,7 +124,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
assert "richard@git.an" in content
|
assert "richard@git.an" in content
|
||||||
assert "comunity@git.an" in content
|
assert "comunity@git.an" in content
|
||||||
assert "skia@git.an" in content
|
assert "skia@git.an" in content
|
||||||
@ -140,7 +140,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
assert "richard@git.an" in content
|
assert "richard@git.an" in content
|
||||||
assert "comunity@git.an" in content
|
assert "comunity@git.an" in content
|
||||||
assert "skia@git.an" in content
|
assert "skia@git.an" in content
|
||||||
@ -158,7 +158,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
assert "richard@git.an" in content
|
assert "richard@git.an" in content
|
||||||
assert "comunity@git.an" in content
|
assert "comunity@git.an" in content
|
||||||
assert "skia@git.an" in content
|
assert "skia@git.an" in content
|
||||||
@ -185,7 +185,7 @@ class TestMailingForm(TestCase):
|
|||||||
assert response.status_code
|
assert response.status_code
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
_("You must specify at least an user or an email address"),
|
_("You must specify at least an user or an email address"),
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
|
|
||||||
# No mailing specified
|
# No mailing specified
|
||||||
@ -197,7 +197,7 @@ class TestMailingForm(TestCase):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert _("This field is required") in response.content.decode()
|
assert _("This field is required") in response.text
|
||||||
|
|
||||||
# One of the selected users doesn't exist
|
# One of the selected users doesn't exist
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
@ -211,7 +211,7 @@ class TestMailingForm(TestCase):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
_("You must specify at least an user or an email address"),
|
_("You must specify at least an user or an email address"),
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
|
|
||||||
# An user has no email address
|
# An user has no email address
|
||||||
@ -229,7 +229,7 @@ class TestMailingForm(TestCase):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
_("One of the selected users doesn't have an email address"),
|
_("One of the selected users doesn't have an email address"),
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.krophil.email = "krophil@git.an"
|
self.krophil.email = "krophil@git.an"
|
||||||
@ -257,7 +257,7 @@ class TestMailingForm(TestCase):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
_("This email is already suscribed in this mailing"),
|
_("This email is already suscribed in this mailing"),
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_remove_subscription_success(self):
|
def test_remove_subscription_success(self):
|
||||||
@ -283,7 +283,7 @@ class TestMailingForm(TestCase):
|
|||||||
|
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
|
|
||||||
assert "comunity@git.an" in content
|
assert "comunity@git.an" in content
|
||||||
assert "richard@git.an" in content
|
assert "richard@git.an" in content
|
||||||
@ -299,7 +299,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
|
|
||||||
assert "comunity@git.an" in content
|
assert "comunity@git.an" in content
|
||||||
assert "richard@git.an" in content
|
assert "richard@git.an" in content
|
||||||
@ -320,7 +320,7 @@ class TestMailingForm(TestCase):
|
|||||||
)
|
)
|
||||||
response = self.client.get(self.mail_url)
|
response = self.client.get(self.mail_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
content = response.content.decode()
|
content = response.text
|
||||||
|
|
||||||
assert "comunity@git.an" not in content
|
assert "comunity@git.an" not in content
|
||||||
assert "richard@git.an" not in content
|
assert "richard@git.an" not in content
|
||||||
|
@ -20,7 +20,7 @@ def test_page_display_on_club_main_page(client: Client):
|
|||||||
res = client.get(reverse("club:club_view", kwargs={"club_id": club.id}))
|
res = client.get(reverse("club:club_view", kwargs={"club_id": club.id}))
|
||||||
|
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
soup = BeautifulSoup(res.content.decode(), "lxml")
|
soup = BeautifulSoup(res.text, "lxml")
|
||||||
detail_html = soup.find(id="club_detail").find(class_="markdown")
|
detail_html = soup.find(id="club_detail").find(class_="markdown")
|
||||||
assertHTMLEqual(detail_html.decode_contents(), markdown(content))
|
assertHTMLEqual(detail_html.decode_contents(), markdown(content))
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ def test_club_main_page_without_content(client: Client):
|
|||||||
res = client.get(reverse("club:club_view", kwargs={"club_id": club.id}))
|
res = client.get(reverse("club:club_view", kwargs={"club_id": club.id}))
|
||||||
|
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
soup = BeautifulSoup(res.content.decode(), "lxml")
|
soup = BeautifulSoup(res.text, "lxml")
|
||||||
detail_html = soup.find(id="club_detail")
|
detail_html = soup.find(id="club_detail")
|
||||||
assert detail_html.find_all("markdown") == []
|
assert detail_html.find_all("markdown") == []
|
||||||
|
@ -125,7 +125,7 @@ class TestUserRegistration:
|
|||||||
error_html = (
|
error_html = (
|
||||||
"<li>Un objet Utilisateur avec ce champ Adresse email existe déjà.</li>"
|
"<li>Un objet Utilisateur avec ce champ Adresse email existe déjà.</li>"
|
||||||
)
|
)
|
||||||
assertInHTML(error_html, str(response.content.decode()))
|
assertInHTML(error_html, str(response.text))
|
||||||
|
|
||||||
def test_register_fail_with_not_existing_email(
|
def test_register_fail_with_not_existing_email(
|
||||||
self, client: Client, valid_payload, monkeypatch
|
self, client: Client, valid_payload, monkeypatch
|
||||||
@ -142,7 +142,7 @@ class TestUserRegistration:
|
|||||||
error_html = (
|
error_html = (
|
||||||
"<li>Nous n'avons pas réussi à vérifier que cette adresse mail existe.</li>"
|
"<li>Nous n'avons pas réussi à vérifier que cette adresse mail existe.</li>"
|
||||||
)
|
)
|
||||||
assertInHTML(error_html, str(response.content.decode()))
|
assertInHTML(error_html, str(response.text))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@ -161,7 +161,7 @@ class TestUserLogin:
|
|||||||
assert (
|
assert (
|
||||||
'<p class="alert alert-red">Votre nom d\'utilisateur '
|
'<p class="alert alert-red">Votre nom d\'utilisateur '
|
||||||
"et votre mot de passe ne correspondent pas. Merci de réessayer.</p>"
|
"et votre mot de passe ne correspondent pas. Merci de réessayer.</p>"
|
||||||
) in str(response.content.decode())
|
) in response.text
|
||||||
assert response.wsgi_request.user.is_anonymous
|
assert response.wsgi_request.user.is_anonymous
|
||||||
|
|
||||||
def test_login_success(self, client, user):
|
def test_login_success(self, client, user):
|
||||||
@ -247,7 +247,7 @@ class TestPageHandling(TestCase):
|
|||||||
|
|
||||||
response = self.client.get(reverse("core:page", kwargs={"page_name": "guy"}))
|
response = self.client.get(reverse("core:page", kwargs={"page_name": "guy"}))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
html = response.content.decode()
|
html = response.text
|
||||||
assert '<a href="/page/guy/hist/">' in html
|
assert '<a href="/page/guy/hist/">' in html
|
||||||
assert '<a href="/page/guy/edit/">' in html
|
assert '<a href="/page/guy/edit/">' in html
|
||||||
assert '<a href="/page/guy/prop/">' in html
|
assert '<a href="/page/guy/prop/">' in html
|
||||||
@ -262,7 +262,7 @@ class TestPageHandling(TestCase):
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# The name and parent inputs should be already filled
|
# The name and parent inputs should be already filled
|
||||||
soup = BeautifulSoup(response.content.decode(), "lxml")
|
soup = BeautifulSoup(response.text, "lxml")
|
||||||
assert soup.find("input", {"name": "name"})["value"] == "new"
|
assert soup.find("input", {"name": "name"})["value"] == "new"
|
||||||
select = soup.find("autocomplete-select", {"name": "parent"})
|
select = soup.find("autocomplete-select", {"name": "parent"})
|
||||||
assert select.find("option", {"selected": True})["value"] == str(parent.id)
|
assert select.find("option", {"selected": True})["value"] == str(parent.id)
|
||||||
@ -279,7 +279,7 @@ class TestPageHandling(TestCase):
|
|||||||
assertRedirects(response, new_url, fetch_redirect_response=False)
|
assertRedirects(response, new_url, fetch_redirect_response=False)
|
||||||
response = self.client.get(new_url)
|
response = self.client.get(new_url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert f'<a href="/page/{parent._full_name}/new/">' in response.content.decode()
|
assert f'<a href="/page/{parent._full_name}/new/">' in response.text
|
||||||
|
|
||||||
def test_access_child_page_ok(self):
|
def test_access_child_page_ok(self):
|
||||||
"""Should display a page correctly."""
|
"""Should display a page correctly."""
|
||||||
@ -291,14 +291,14 @@ class TestPageHandling(TestCase):
|
|||||||
reverse("core:page", kwargs={"page_name": "guy/bibou"})
|
reverse("core:page", kwargs={"page_name": "guy/bibou"})
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
html = response.content.decode()
|
html = response.text
|
||||||
self.assertIn('<a href="/page/guy/bibou/edit/">', html)
|
self.assertIn('<a href="/page/guy/bibou/edit/">', html)
|
||||||
|
|
||||||
def test_access_page_not_found(self):
|
def test_access_page_not_found(self):
|
||||||
"""Should not display a page correctly."""
|
"""Should not display a page correctly."""
|
||||||
response = self.client.get(reverse("core:page", kwargs={"page_name": "swagg"}))
|
response = self.client.get(reverse("core:page", kwargs={"page_name": "swagg"}))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
html = response.content.decode()
|
html = response.text
|
||||||
self.assertIn('<a href="/page/create/?page=swagg">', html)
|
self.assertIn('<a href="/page/create/?page=swagg">', html)
|
||||||
|
|
||||||
def test_create_page_markdown_safe(self):
|
def test_create_page_markdown_safe(self):
|
||||||
@ -332,7 +332,7 @@ http://git.an
|
|||||||
<p><guy>Bibou</guy></p>
|
<p><guy>Bibou</guy></p>
|
||||||
<p><script>alert('Guy');</script></p>
|
<p><script>alert('Guy');</script></p>
|
||||||
"""
|
"""
|
||||||
assertInHTML(expected, response.content.decode())
|
assertInHTML(expected, response.text)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -123,11 +123,11 @@ class TestEboutic(TestCase):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
"<tr><td>Cotis 2 semestres</td><td>1</td><td>28.00 €</td></tr>",
|
"<tr><td>Cotis 2 semestres</td><td>1</td><td>28.00 €</td></tr>",
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
"<tr><td>Barbar</td><td>3</td><td>1.70 €</td></tr>",
|
"<tr><td>Barbar</td><td>3</td><td>1.70 €</td></tr>",
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
assert "basket_id" in self.client.session
|
assert "basket_id" in self.client.session
|
||||||
basket = Basket.objects.get(id=self.client.session["basket_id"])
|
basket = Basket.objects.get(id=self.client.session["basket_id"])
|
||||||
@ -178,7 +178,7 @@ class TestEboutic(TestCase):
|
|||||||
response = self.client.get(reverse("eboutic:command"))
|
response = self.client.get(reverse("eboutic:command"))
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
"<tr><td>Cotis 2 semestres</td><td>1</td><td>28.00 €</td></tr>",
|
"<tr><td>Cotis 2 semestres</td><td>1</td><td>28.00 €</td></tr>",
|
||||||
response.content.decode(),
|
response.text,
|
||||||
)
|
)
|
||||||
basket = Basket.objects.get(id=self.client.session["basket_id"])
|
basket = Basket.objects.get(id=self.client.session["basket_id"])
|
||||||
assert basket.items.count() == 1
|
assert basket.items.count() == 1
|
||||||
@ -206,7 +206,7 @@ class TestEboutic(TestCase):
|
|||||||
url = self.generate_bank_valid_answer()
|
url = self.generate_bank_valid_answer()
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.content.decode() == "Payment successful"
|
assert response.text == "Payment successful"
|
||||||
new_balance = Customer.objects.get(user=self.subscriber).amount
|
new_balance = Customer.objects.get(user=self.subscriber).amount
|
||||||
assert new_balance == initial_balance + 15
|
assert new_balance == initial_balance + 15
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class TestSasModeration(TestCase):
|
|||||||
assertInHTML(
|
assertInHTML(
|
||||||
'<ul class="errorlist nonfield"><li>'
|
'<ul class="errorlist nonfield"><li>'
|
||||||
"Vous avez déjà déposé une demande de retrait pour cette photo.</li></ul>",
|
"Vous avez déjà déposé une demande de retrait pour cette photo.</li></ul>",
|
||||||
res.content.decode(),
|
res.text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user