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 billetera_crear(request): form = BilleteraElectronicaForm() if request.method == 'POST': form = BilleteraElectronicaForm(request.POST) if form.is_valid(): billetera = BilleteraElectronica( nombreUsuario = form.cleaned_data['nombre'], apellidoUsuario = form.cleaned_data['apellido'], cedulaTipo = form.cleaned_data['cedulaTipo'], cedula = form.cleaned_data['cedula'], PIN = form.cleaned_data['pin'], saldo = Decimal(0).quantize(Decimal('1.00')) ) billetera.save(); return render( request, 'crearbilletera.html', { "billetera" : billetera , "color" : "green" , 'mensaje' : "Se ha creado la billetera satisfactoriamente." } ) return render( request, 'crearbilletera.html', { 'form' : form } )
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 crear_billetera(monto=0): r = BilleteraElectronica(nombre="Daniel", apellido="Nuñez", cedula="10", cedulaTipo="V", PIN="1234", saldo=monto) r.save()
def testConsultaSaldoNulo(self): billetera = BilleteraElectronica(nombre='Alejandro', apellido='Banega', cedula="12345678", cedulaTipo='V', PIN="1234") billetera.save() billeteraE = BilleteraElectronica.objects.get(pk=1) self.assertEqual(billeteraE.saldo, 0)
def crear_billetera(monto = 0): r = BilleteraElectronica( nombre = "Daniel", apellido = "Nuñez", cedula = "10", cedulaTipo = "V", PIN = "1234", saldo = monto ) r.save()
def test_AutenticarBilletera(self): billetera1 = BilleteraElectronica(cedula = '10', cedulaTipo = 'V', nombre = 'Maria', apellido = 'Perez', saldo = 0.00, PIN = '1234') billetera1.save() billetera = billetera_autenticar(1, "1234") self.assertEqual(billetera1, billetera)
def test_AutenticarIDinvalido(self): billetera = BilleteraElectronica(cedula = '10', cedulaTipo = 'V', nombre = 'Maria', apellido = 'Perez', saldo = 0.00, PIN = '1234') billetera.save() billetera1 = billetera_autenticar(2, '1234') self.assertNotEqual(billetera, billetera1)
def test_AutenticarPINinvalido(self): billetera = BilleteraElectronica(cedula = '11', cedulaTipo = 'V', nombre = 'Mario', apellido = 'Jimenez', saldo = 0.00, PIN = '1234') billetera.save() billetera1 = billetera_autenticar(1, '1235') self.assertEqual(billetera1, None)
def test_AutenticarPINinvalido(self): billetera = BilleteraElectronica(cedula='11', cedulaTipo='V', nombre='Mario', apellido='Jimenez', saldo=0.00, PIN='1234') billetera.save() billetera1 = billetera_autenticar(1, '1235') self.assertEqual(billetera1, None)
def test_AutenticarBilletera(self): billetera1 = BilleteraElectronica(cedula='10', cedulaTipo='V', nombre='Maria', apellido='Perez', saldo=0.00, PIN='1234') billetera1.save() billetera = billetera_autenticar(1, "1234") self.assertEqual(billetera1, billetera)
def test_AutenticarIDinvalido(self): billetera = BilleteraElectronica(cedula='10', cedulaTipo='V', nombre='Maria', apellido='Perez', saldo=0.00, PIN='1234') billetera.save() billetera1 = billetera_autenticar(2, '1234') self.assertNotEqual(billetera, billetera1)
def testConsultaSaldoNulo(self): billetera = BilleteraElectronica( nombre = 'Alejandro', apellido = 'Banega', cedula = "12345678", cedulaTipo = 'V', PIN = "1234" ) billetera.save() billeteraE = BilleteraElectronica.objects.get(pk = 1) self.assertEqual(billeteraE.saldo, 0)