Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/test validar telefono #44

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/tests_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ def test_invalid_email_not_ending_with_com(self):

self.assertIn("El email debe tener un formato válido y ser de la forma [email protected]", errors.values())

def test_phone_number_without_54(self):
client_data = {
"name": "Juan Sebastian Veron",
"phone": "2245556789",
"city": "La Plata",
"email": "[email protected]",
}
errors = validate_client(client_data)
self.assertIn("phone", errors)
self.assertEqual(errors["phone"], "El telefono debe comenzar con 54")

class MedicineModelTest(TestCase):
"""
Expand Down
19 changes: 19 additions & 0 deletions functional_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,25 @@ def test_should_view_errors_if_form_is_invalid_email(self):
expect(self.page.get_by_text("[email protected]")).to_be_visible()
expect(self.page.get_by_text("La Plata")).to_be_visible()

def test_should_show_error_for_phone_whitout_54(self):
"""
Esta función verifica que se muestre un mensaje de error cuando se intenta
crear un cliente con un numero sin el 54
"""
self.page.goto(f"{self.live_server_url}{reverse('clients_form')}")

expect(self.page.get_by_role("form")).to_be_visible()

self.page.get_by_label("Nombre").fill("Guido Carrillo")
self.page.get_by_label("Teléfono").fill("221232555")
self.page.get_by_label("Email").fill("[email protected]")
self.page.get_by_label("Ciudad").select_option("Berisso")

self.page.get_by_role("button", name="Guardar").click()

# Verifica si se muestra el mensaje de error esperado
expect(self.page.get_by_text("El telefono debe comenzar con 54")).to_be_visible()


class MedicineCreateEditTestCase(PlaywrightTestCase):
"""
Expand Down
Loading