def test_delete(self): print('-----------\n') new_notebook = Notebook() new_notebook.add('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=20) new_notebook.add('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=19) new_notebook.add('Igor', 'Puzanov', 'Mixail', home_address='Izhevsk', phone_number='55-00-55', age=18) new_notebook.add('Igor', 'Puzanov', 'Alex', home_address='Izhevsk', phone_number='55-00-55', age=17) print(new_notebook.length()) for man in new_notebook.people: print(man) new_notebook.delete(2) print(new_notebook.length()) for man in new_notebook.people: print(man)
def test_change(self): print('-----------\n') new_notebook = Notebook() new_notebook.add('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=20) new_notebook.add('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=19) new_notebook.add('Igor', 'Puzanov', 'Mixail', home_address='Izhevsk', phone_number='55-00-55', age=18) print(new_notebook.length()) for man in new_notebook.people: print(man) new_notebook.change(1, middle_name='Alex') for man in new_notebook.people: print(man) new_notebook.change(first_name='Alo') for man in new_notebook.people: print(man) print('\n\n\n') print(new_notebook.find("Igor Puzanov Mixail"))
def test_odd(self): new_notebook = Notebook() new_man = Man('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=20) new_notebook.odd(new_man) new_notebook.odd('hello') print(new_notebook.length()) self.assertEqual( new_notebook.people[0].data(), Man('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=20).data()) self.assertEqual(new_notebook.length(), 1)
def test_record_and_read(self): new_notebook = Notebook() new_notebook.add('Igor', 'Puzanov', home_address='Izhevsk', phone_number='55-00-55', age=20) new_notebook.record() new_notebook.read() self.assertEqual(new_notebook.length(), 2)
home_address=home_address, phone_number=phone_number, age=age) print('--запись изменина--') elif answer == 'F': print('--введите фамилию человека, которого хотите найти--') name = input() values = notebook.find(name) if values == 'Такого человека нет :(': print(values) else: print(f'Индекс записи {values[0]}') print('Информация о человеке:') print(values[1]) elif answer == 'P': if notebook.length() == 0: print('К сожалению, пока что нет ни одной записи :(') for man in notebook.people: print('--------------------') print('Номер записи: ', notebook.people.index(man) + 1) print(man) print('--------------------') elif answer == 'Z': notebook.record() print('Notebook is record') elif answer == 'Q': print(notebook.read()) print('Notebook is read') print('чтобы посмотреть все записи нажмите P') elif answer == 'E': print('GOOD BYE')