def crearBilletera(cedul, cedulaTipo): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': cedul, 'PIN': '1234', 'cedulaTipo': cedulaTipo } form = BilleteraForm(data = form_data) billetera = BilleteraElectronica.objects.all() if form.is_valid(): if len(billetera) == 9999: pass #elif not BilleteraElectronica.objects.filter(cedula=form.cleaned_data['cedula']).exists(): else: obj = BilleteraElectronica( nombre = form.cleaned_data['nombre'], apellido = form.cleaned_data['apellido'], PIN = form.cleaned_data['PIN'], cedula = form.cleaned_data['cedula'], saldo = 0.00, cedulaTipo = form.cleaned_data['cedulaTipo'] ) try: with transaction.atomic(): obj.save() except (IntegrityError): pass
def crearBilletera(cedul, cedulaTipo): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': cedul, 'PIN': '1234', 'cedulaTipo': cedulaTipo } form = BilleteraForm(data=form_data) billetera = BilleteraElectronica.objects.all() if form.is_valid(): if len(billetera) == 9999: pass #elif not BilleteraElectronica.objects.filter(cedula=form.cleaned_data['cedula']).exists(): else: obj = BilleteraElectronica( nombre=form.cleaned_data['nombre'], apellido=form.cleaned_data['apellido'], PIN=form.cleaned_data['PIN'], cedula=form.cleaned_data['cedula'], saldo=0.00, cedulaTipo=form.cleaned_data['cedulaTipo']) try: with transaction.atomic(): obj.save() except (IntegrityError): pass
def testCrearBilleteraForm_DosCampos(self): form_data = { 'nombre': 'Neo', 'apellido': 'Noria' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_TresCampos(self): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': '12345678' } form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_TresCampos(self): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': '12345678' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_CincoCampos(self): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': '12345678', 'PIN': '1234', 'cedulaTipo': 'V' } form = BilleteraForm(data=form_data) self.assertTrue(form.is_valid())
def testCrearBilleteraForm_CincoCampos(self): form_data = { 'nombre': 'Carlos', 'apellido': 'Perez', 'cedula': '12345678', 'PIN': '1234', 'cedulaTipo': 'V' } form = BilleteraForm(data = form_data) self.assertTrue(form.is_valid())
def testBilleteraForm_CedulaLimiteInferior(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '0', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data=form_data) self.assertTrue(form.is_valid())
def testBilleteraForm_NombreInvalidoSimbolos(self): form_data = { 'nombre': 'Jose .', 'apellido': 'Perez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testBilleteraForm_NombreInvalidoSimbolos(self): form_data = { 'nombre': 'Jose .', 'apellido': 'Perez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testBilleteraForm_PINLimiteSuperior(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '9999', 'identificador': '9999999999999999' } form = BilleteraForm(data=form_data) self.assertTrue(form.is_valid())
def testBilleteraForm_PINInvalidoEspacio(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '12 34', 'identificador': '9999999999999999' } form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testBilleteraForm_CedulaLimiteInferior(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '0', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data = form_data) self.assertTrue(form.is_valid())
def testBilleteraForm_ApellidoInvalidoDigitos(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez1', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testBilleteraForm_ApellidoInvalidoDigitos(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez1', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '1234', 'identificador': '1000100010001000' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testBilleteraForm_PINLimiteSuperior(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '9999', 'identificador': '9999999999999999' } form = BilleteraForm(data = form_data) self.assertTrue(form.is_valid())
def testBilleteraForm_PINInvalidoEspacio(self): form_data = { 'nombre': 'Jose', 'apellido': 'Perez Martinez', 'cedula': '12345678', 'cedulaTipo': 'V', 'PIN': '12 34', 'identificador': '9999999999999999' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_UnCampo(self): form_data = {'nombre': 'Andrea'} form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_DosCampos(self): form_data = {'nombre': 'Neo', 'apellido': 'Noria'} form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_UnCampo(self): form_data = { 'nombre': 'Andrea' } form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_Vacio(self): form_data = {} form = BilleteraForm(data = form_data) self.assertFalse(form.is_valid())
def testCrearBilleteraForm_Vacio(self): form_data = {} form = BilleteraForm(data=form_data) self.assertFalse(form.is_valid())