mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 09:03:06 +00:00 
			
		
		
		
	response.content.decode() => response.text
				
					
				
			This commit is contained in:
		| @@ -34,7 +34,7 @@ class Command(BaseCommand): | ||||
|                     f"Source {provider} responded with code {res.status_code}" | ||||
|                 ) | ||||
|                 continue | ||||
|             domains |= set(res.content.decode().splitlines()) | ||||
|             domains |= set(res.text.splitlines()) | ||||
|         return domains | ||||
|  | ||||
|     def _update_domains(self, domains: set[str]): | ||||
|   | ||||
| @@ -38,7 +38,7 @@ class TestMailingForm(TestCase): | ||||
|         self.assertRedirects(response, self.mail_url) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         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 | ||||
|         self.client.force_login(self.root) | ||||
| @@ -48,7 +48,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         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): | ||||
|         self.client.force_login(self.rbatsbak) | ||||
| @@ -58,7 +58,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|         assert "Liste de diffusion mde@utbm.fr" not in content | ||||
|         assert "<p>Listes de diffusions en attente de modération</p>" in content | ||||
|         assert "<li>mde@utbm.fr" in content | ||||
| @@ -90,7 +90,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         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): | ||||
|         # Prepare mailing list | ||||
| @@ -111,7 +111,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         assert "skia@git.an" in response.content.decode() | ||||
|         assert "skia@git.an" in response.text | ||||
|  | ||||
|         # Add multiple users | ||||
|         self.client.post( | ||||
| @@ -124,7 +124,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|         assert "richard@git.an" in content | ||||
|         assert "comunity@git.an" in content | ||||
|         assert "skia@git.an" in content | ||||
| @@ -140,7 +140,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|         assert "richard@git.an" in content | ||||
|         assert "comunity@git.an" in content | ||||
|         assert "skia@git.an" in content | ||||
| @@ -158,7 +158,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|         assert "richard@git.an" in content | ||||
|         assert "comunity@git.an" in content | ||||
|         assert "skia@git.an" in content | ||||
| @@ -185,7 +185,7 @@ class TestMailingForm(TestCase): | ||||
|         assert response.status_code | ||||
|         self.assertInHTML( | ||||
|             _("You must specify at least an user or an email address"), | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|  | ||||
|         # No mailing specified | ||||
| @@ -197,7 +197,7 @@ class TestMailingForm(TestCase): | ||||
|             }, | ||||
|         ) | ||||
|         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 | ||||
|         response = self.client.post( | ||||
| @@ -211,7 +211,7 @@ class TestMailingForm(TestCase): | ||||
|         assert response.status_code == 200 | ||||
|         self.assertInHTML( | ||||
|             _("You must specify at least an user or an email address"), | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|  | ||||
|         # An user has no email address | ||||
| @@ -229,7 +229,7 @@ class TestMailingForm(TestCase): | ||||
|         assert response.status_code == 200 | ||||
|         self.assertInHTML( | ||||
|             _("One of the selected users doesn't have an email address"), | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|  | ||||
|         self.krophil.email = "krophil@git.an" | ||||
| @@ -257,7 +257,7 @@ class TestMailingForm(TestCase): | ||||
|         assert response.status_code == 200 | ||||
|         self.assertInHTML( | ||||
|             _("This email is already suscribed in this mailing"), | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|  | ||||
|     def test_remove_subscription_success(self): | ||||
| @@ -283,7 +283,7 @@ class TestMailingForm(TestCase): | ||||
|  | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|  | ||||
|         assert "comunity@git.an" in content | ||||
|         assert "richard@git.an" in content | ||||
| @@ -299,7 +299,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|  | ||||
|         assert "comunity@git.an" in content | ||||
|         assert "richard@git.an" in content | ||||
| @@ -320,7 +320,7 @@ class TestMailingForm(TestCase): | ||||
|         ) | ||||
|         response = self.client.get(self.mail_url) | ||||
|         assert response.status_code == 200 | ||||
|         content = response.content.decode() | ||||
|         content = response.text | ||||
|  | ||||
|         assert "comunity@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})) | ||||
|  | ||||
|     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") | ||||
|     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})) | ||||
|  | ||||
|     assert res.status_code == 200 | ||||
|     soup = BeautifulSoup(res.content.decode(), "lxml") | ||||
|     soup = BeautifulSoup(res.text, "lxml") | ||||
|     detail_html = soup.find(id="club_detail") | ||||
|     assert detail_html.find_all("markdown") == [] | ||||
|   | ||||
| @@ -125,7 +125,7 @@ class TestUserRegistration: | ||||
|         error_html = ( | ||||
|             "<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( | ||||
|         self, client: Client, valid_payload, monkeypatch | ||||
| @@ -142,7 +142,7 @@ class TestUserRegistration: | ||||
|         error_html = ( | ||||
|             "<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 | ||||
| @@ -161,7 +161,7 @@ class TestUserLogin: | ||||
|         assert ( | ||||
|             '<p class="alert alert-red">Votre nom d\'utilisateur ' | ||||
|             "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 | ||||
|  | ||||
|     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"})) | ||||
|         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/edit/">' in html | ||||
|         assert '<a href="/page/guy/prop/">' in html | ||||
| @@ -262,7 +262,7 @@ class TestPageHandling(TestCase): | ||||
|  | ||||
|         assert response.status_code == 200 | ||||
|         # 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" | ||||
|         select = soup.find("autocomplete-select", {"name": "parent"}) | ||||
|         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) | ||||
|         response = self.client.get(new_url) | ||||
|         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): | ||||
|         """Should display a page correctly.""" | ||||
| @@ -291,14 +291,14 @@ class TestPageHandling(TestCase): | ||||
|             reverse("core:page", kwargs={"page_name": "guy/bibou"}) | ||||
|         ) | ||||
|         assert response.status_code == 200 | ||||
|         html = response.content.decode() | ||||
|         html = response.text | ||||
|         self.assertIn('<a href="/page/guy/bibou/edit/">', html) | ||||
|  | ||||
|     def test_access_page_not_found(self): | ||||
|         """Should not display a page correctly.""" | ||||
|         response = self.client.get(reverse("core:page", kwargs={"page_name": "swagg"})) | ||||
|         assert response.status_code == 200 | ||||
|         html = response.content.decode() | ||||
|         html = response.text | ||||
|         self.assertIn('<a href="/page/create/?page=swagg">', html) | ||||
|  | ||||
|     def test_create_page_markdown_safe(self): | ||||
| @@ -332,7 +332,7 @@ http://git.an | ||||
|             <p><guy>Bibou</guy></p> | ||||
|             <p><script>alert('Guy');</script></p> | ||||
|             """ | ||||
|         assertInHTML(expected, response.content.decode()) | ||||
|         assertInHTML(expected, response.text) | ||||
|  | ||||
|  | ||||
| @pytest.mark.django_db | ||||
|   | ||||
| @@ -123,11 +123,11 @@ class TestEboutic(TestCase): | ||||
|         assert response.status_code == 200 | ||||
|         self.assertInHTML( | ||||
|             "<tr><td>Cotis 2 semestres</td><td>1</td><td>28.00 €</td></tr>", | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|         self.assertInHTML( | ||||
|             "<tr><td>Barbar</td><td>3</td><td>1.70 €</td></tr>", | ||||
|             response.content.decode(), | ||||
|             response.text, | ||||
|         ) | ||||
|         assert "basket_id" in self.client.session | ||||
|         basket = Basket.objects.get(id=self.client.session["basket_id"]) | ||||
| @@ -178,7 +178,7 @@ class TestEboutic(TestCase): | ||||
|         response = self.client.get(reverse("eboutic:command")) | ||||
|         self.assertInHTML( | ||||
|             "<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"]) | ||||
|         assert basket.items.count() == 1 | ||||
| @@ -206,7 +206,7 @@ class TestEboutic(TestCase): | ||||
|         url = self.generate_bank_valid_answer() | ||||
|         response = self.client.get(url) | ||||
|         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 | ||||
|         assert new_balance == initial_balance + 15 | ||||
|  | ||||
|   | ||||
| @@ -169,7 +169,7 @@ class TestSasModeration(TestCase): | ||||
|         assertInHTML( | ||||
|             '<ul class="errorlist nonfield"><li>' | ||||
|             "Vous avez déjà déposé une demande de retrait pour cette photo.</li></ul>", | ||||
|             res.content.decode(), | ||||
|             res.text, | ||||
|         ) | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user