def issuer_register(request): if request.method == 'POST': form = IssuerForm(request.POST) form.is_valid() obj = Issuer(**form.cleaned_data) obj.save() return HttpResponseRedirect('/emitente/%d/' % obj.pk) else: return direct_to_template( request , 'registers/issuer_form.xhtml' , {'form': IssuerForm()} )
class IssuerTest(TestCase): def setUp(self): self.obj = Issuer( name = 'Fatec Ourinhos' ) def test_create_issuer(self): 'Issuer must have name.' self.obj.save() self.assertEqual(1, self.obj.id) def test_unicode(self): 'Must be return a unicode.' self.assertEqual(u'Fatec Ourinhos', unicode(self.obj))
def setUp(self): self.obj = Issuer( name = 'Fatec Ourinhos' )