def testEditContact(self): a = Contact("vasya", "petrov", "222") b = ContactBook() b.addContact(a) b.editContact("vasya", "petya", "petrov", "222") a = b.getContactByName("petya") self.assertIsInstance(a, Contact)
def start(): """ start the program :return: """ book = ContactBook() while True: key = Control().showMenu() if key == '1': Control.addInput(book) elif key == "2": Control().editInput(book) elif key == "3": Control().deleteInput(book) elif key == "4": book.sortByLength() elif key == "5": View().showBook(book) elif key == "6": View().showContact(book) elif key == "7": Control().serialInput(book) elif key == "8": exit() else: print("Incorrect. Please,try again")
def decode(obj): """ :param obj: :return: """ tmpBook = ContactBook() for dic in obj: tmpContact = Contact(dic["Name"], dic["Surname"], dic["Number"]) tmpBook.addContact(tmpContact) return tmpBook
def testReload(self): b = ContactBook() lst = [1, 2, 3] b.reload(lst) self.assertListEqual(b.listBook, lst)
def testDeleteContact(self): a = Contact("vasya", "petrov", "222") b = ContactBook() b.addContact(a) b.deleteContactByName("vasya") self.assertNotIn(a, b.listBook)
def testAddContact(self): a = Contact("vasya", "petrov", "222") b = ContactBook() b.addContact(a) self.assertIn(a, b.listBook)
def showInput(): read, write = Model().setTypeSerial() book = ContactBook(read()) Control().showInput(book)
def deleteInput(): read, write = Model().setTypeSerial() book = ContactBook(read()) Control().deleteInput(book) write(book)