forked from frlp-utn-ingsoft/vetsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from GonzaloEBaez/bugfix/validar-campo-numerico
Bugfix/validar campo numerico
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,21 @@ def test_phone_number_without_54(self): | |
self.assertIn("phone", errors) | ||
self.assertEqual(errors["phone"], "El telefono debe comenzar con 54") | ||
|
||
def test_phone_number_with_a_letter(self): | ||
""" | ||
La funcion verifica que el campo solo tengo caracteres numericos | ||
""" | ||
client_data = { | ||
"name": "Juan Sebastian Veron", | ||
"phone": "a2245556789", | ||
"city": "La Plata", | ||
"email": "[email protected]", | ||
} | ||
errors = validate_client(client_data) | ||
self.assertIn("phone", errors) | ||
self.assertEqual(errors["phone"], "El teléfono solo debe contener números") | ||
|
||
class MedicineModelTest(TestCase): | ||
""" | ||
Pruebas para el modelo Medicina. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,29 @@ def test_should_show_error_for_phone_whitout_54(self): | |
# Verifica si se muestra el mensaje de error esperado | ||
expect(self.page.get_by_text("El telefono debe comenzar con 54")).to_be_visible() | ||
|
||
def test_should_show_error_for_phone_with_characters(self): | ||
""" | ||
Verifica que se muestre un mensaje de error al intentar crear un cliente con un teléfono no numérico. | ||
""" | ||
url = reverse('clients_form') | ||
data = { | ||
"name": "Guido Carrillo", | ||
"phone": "aa54221232555", # Teléfono con caracteres no numéricos | ||
"email": "[email protected]", | ||
"city": "Berisso", | ||
} | ||
|
||
response = self.client.post(url, data, follow=True) | ||
|
||
# Verificar que se ha mostrado el mensaje de error esperado en la respuesta | ||
self.assertContains(response, "El teléfono solo debe contener números") | ||
|
||
# Verificar que no se ha creado un cliente en la base de datos | ||
clients = Client.objects.filter(name="Guido Carrillo") | ||
self.assertEqual(clients.count(), 0) | ||
|
||
# Verificar que estamos en la página correcta después del envío del formulario | ||
self.assertTemplateUsed(response, 'clients_form.html') | ||
|
||
class MedicineCreateEditTestCase(PlaywrightTestCase): | ||
""" | ||
|