예제 #1
0
 def testFormWithNoPhoneNumber(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({'name':NAME}, instance=contact)
     self.assertFalse(form.is_valid())
     form = CommoditiesContactForm({'name':NAME, 'phone':PHONE}, instance=contact)
     self.assertTrue(form.is_valid())
예제 #2
0
 def testSaveSameContactTwice(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({
         'name': NAME,
         'phone': PHONE
     },
                                   instance=contact)
     self.assertTrue(form.is_valid())
     # this time around, the form should NOT throw an error on re-registration
     contact.save()
     contact.set_default_connection_identity(PHONE,
                                             settings.DEFAULT_BACKEND)
     form = CommoditiesContactForm({
         'name': NAME,
         'phone': PHONE
     },
                                   instance=contact)
     self.assertTrue(form.is_valid())
     # this time around, the form should throw an error on duplicate registration
     NEWNAME = "newname"
     new_contact = Contact(name=NEWNAME)
     form = CommoditiesContactForm({
         'name': NEWNAME,
         'phone': PHONE
     },
                                   instance=new_contact)
     self.assertFalse(form.is_valid())
예제 #3
0
 def testFormWithNoPhoneNumber(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({'name': NAME}, instance=contact)
     self.assertFalse(form.is_valid())
     form = CommoditiesContactForm({
         'name': NAME,
         'phone': PHONE
     },
                                   instance=contact)
     self.assertTrue(form.is_valid())
예제 #4
0
 def testSaveSameContactTwice(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({'name':NAME, 'phone':PHONE}, instance=contact)
     self.assertTrue(form.is_valid())
     # this time around, the form should NOT throw an error on re-registration
     contact.save()
     contact.set_default_connection_identity(PHONE, settings.DEFAULT_BACKEND)
     form = CommoditiesContactForm({'name':NAME, 'phone':PHONE}, instance=contact)
     self.assertTrue(form.is_valid())
     # this time around, the form should throw an error on duplicate registration
     NEWNAME = "newname"
     new_contact = Contact(name=NEWNAME)
     form = CommoditiesContactForm({'name':NEWNAME, 'phone':PHONE}, instance=new_contact)
     self.assertFalse(form.is_valid())
예제 #5
0
 def testEmptyInstance(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({'name':NAME}, instance=None)
     self.assertFalse(form.is_valid())
예제 #6
0
 def testEmptyInstance(self):
     NAME = "newuser"
     PHONE = "+233123"
     contact = Contact(name=NAME)
     form = CommoditiesContactForm({'name': NAME}, instance=None)
     self.assertFalse(form.is_valid())