def test_contact_exists(self): test_contact = Contact("Test", "user", "0711223344", "*****@*****.**") # new contact test_contact.save_contact() contact_exists = Contact.contact_exists("0711223344") # Checks whether the value returned is true... self.assertTrue(contact_exists)
def test_find_contact_by_number(self): self.new_contact.save_contact() test_contact = Contact("Test", "user", "0712345678", "*****@*****.**") # new contact test_contact.save_contact() found_contact = Contact.find_by_number("0712345678") self.assertEqual(found_contact.email, test_contact.email)
def test_contact_exists(self): self.new_contact.save_contact() test_contact = Contact("Test", "user", "0711223344", "*****@*****.**") # new contact test_contact.save_contact() contact_exists = Contact.contact_exists("0711223344") self.assertTrue(contact_exists)
def test_delete_contact(self): # You've saved two contacts self.new_contact.save_contact() test_contact = Contact("Test","user","0712345678","*****@*****.**") # new contact test_contact.save_contact() self.new_contact.delete_contact() test_contact.delete_contact() self.assertEqual(len(Contact.contact_list),0)
def new_contact(self): name = input("Name: ") phone = input("Phone: ") email = input("Email: ") person = Contact(name, phone, email) self.contact_list.append(person) print("The entry has been added")
def contact_update(self): try: self.selected_item = self.listbox.selection()[0] values = tuple(self.listbox.item(self.selected_item)['values']) self.update = Contact(self) self.update.contact_update_form(values[0]) except IndexError: msgbox.showerror("error", "First Select the Item")
def change_contact(self): cname = input("Enter a name: ") for contact in self.contact_list: if cname == contact.name: self.delete_contact(cname) name = input("Name: ") phone = input("Phone: ") email = input("Email: ") person = Contact(name, phone, email) self.contact_list.append(person)
def contact_create(self): self.create = Contact(self) self.create.contact_create_form()
def setUp(self): ''' set up method that should run before each test case ''' self.new_contact = Contact("Maryanne", "Njeri", "071234567", "*****@*****.**")
def test_save_multiple_contacts(self): self.new_contact.save_contact() test_contact = Contact("Test", "user", "0712345678", "*****@*****.**") # new contact test_contact.save_contact() self.assertEqual(len(Contact.contact_list), 2)
def create_contact(fname, lname, phone, email): new_contact = Contact(fname, lname, phone, email) return new_contact