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())
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())
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())
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())
def testEmptyInstance(self): NAME = "newuser" PHONE = "+233123" contact = Contact(name=NAME) form = CommoditiesContactForm({'name':NAME}, instance=None) self.assertFalse(form.is_valid())
def testEmptyInstance(self): NAME = "newuser" PHONE = "+233123" contact = Contact(name=NAME) form = CommoditiesContactForm({'name': NAME}, instance=None) self.assertFalse(form.is_valid())