From 270c3aaa4be86cd591dfd617811b764a11e4cc44 Mon Sep 17 00:00:00 2001 From: alfcadmorUS Date: Sun, 18 Dec 2022 19:05:34 +0100 Subject: [PATCH] feat: implementos tests para formulario registro --- decide/authentication/test_registro.py | 44 ++++++++++++++++++++++++++ decide/authentication/tests.py | 2 ++ 2 files changed, 46 insertions(+) diff --git a/decide/authentication/test_registro.py b/decide/authentication/test_registro.py index 0b887f78b8..7b2ea1af4a 100644 --- a/decide/authentication/test_registro.py +++ b/decide/authentication/test_registro.py @@ -4,6 +4,7 @@ from base.tests import BaseTestCase from selenium.webdriver.common.by import By from django.contrib.auth.models import User +from .views import * class testRegistro(StaticLiveServerTestCase): def setUp(self): @@ -39,3 +40,46 @@ def testRegistroCorrecto(self): #Comprobar redireccion y existencia del perfil assert User.objects.get(username='Voter1').email == 'voter1@gmail.com' + +class AuthPageTextCase(TestCase): + def test_form_no_username(self): + #username ,password1 , password2, email , sex , age , status ,country , discord_account + form= PersonForm({'password1':'Probando189!','password2':'Probando189!','email':'prueba@decide.es','status':'soltero','sex':'hombre','country':'NZ','discord_account':'prueba#1111'}) + + #form = register(data={'email':'prueba@decide.es','password':'password123','sexo':'mujer','edad':'20'}) + + self.assertEquals(form.errors['username'], ["This field is required."]) + + def test_form_no_status(self): + #form = register(data={'username':'prueba','password':'password123','sexo':'mujer','edad':'20'}) + form= PersonForm({'username':'prueba','password1':'Probando189!','password2':'Probando189!','email':'prueba@decide.es','sex':'hombre','country':'NZ','discord_account':'prueba#1111'}) + + self.assertEquals(form.errors['status'], ["This field is required."]) + + def test_form_no_password1(self): + #form = register(data={'email':'prueba@decide.es','username':'prueba','sexo':'mujer','edad':'20'}) + form= PersonForm({'username':'prueba','password2':'Probando189!','email':'prueba@decide.es','status':'soltero','sex':'hombre','country':'NZ','discord_account':'prueba#1111'}) + + self.assertEquals(form.errors['password1'], ["This field is required."]) + + def test_form_no_password2(self): + #form = register(data={'email':'prueba@decide.es','username':'prueba','sexo':'mujer','edad':'20'}) + form= PersonForm({'username':'prueba','password1':'Probando189!','email':'prueba@decide.es','status':'soltero','sex':'hombre','country':'NZ','discord_account':'prueba#1111'}) + + self.assertEquals(form.errors['password2'], ["This field is required."]) + + def test_form_no_sex(self): + #form = register(data={'email':'prueba@decide.es','password':'password123','username':'prueba','edad':'20'}) + form= PersonForm({'username':'prueba','password1':'Probando189!','email':'prueba@decide.es','status':'soltero','country':'NZ','discord_account':'prueba#1111'}) + + + self.assertEquals(form.errors['sex'], ["This field is required."]) + + def test_form_no_country(self): + #form = register(data={'username':'prueba','password':'password123','sexo':'mujer','edad':'20'}) + form= PersonForm({'username':'prueba','password1':'Probando189!','password2':'Probando189!','email':'prueba@decide.es','status':'soltero','sex':'hombre','discord_account':'prueba#1111'}) + + self.assertEquals(form.errors['country'], ["This field is required."]) + + + diff --git a/decide/authentication/tests.py b/decide/authentication/tests.py index 7b6d994557..7ab186d1c6 100644 --- a/decide/authentication/tests.py +++ b/decide/authentication/tests.py @@ -603,3 +603,5 @@ def test_simpleIncorrectDiscordAccountComplete(self): self.driver.find_element(By.ID,'id_button').send_keys(Keys.ENTER) self.assertEqual(self.driver.title, 'Complete') + +