Example #1
0
    def test_find_person_by_number(self):
        human = obj.Person()
        human.create_from_name_and_birthday('John', 'Snow', obj.Date(1673, 05, 12))
        human.set_middle_name('Bastard')
        human.set_number()

        book = obj.Book()
        book.load_from_file('Book.txt')
        other_human = book.find_person_by_number(human.number)
        self.assertEqual(human.to_string(), other_human.to_string(['first', 'middle', 'last', 'birthday']))
Example #2
0
    def test_load_from_file(self):
        human = obj.Person()
        human.create_from_name_and_birthday('Ivan', 'Morozoff', obj.Date(1950, 8, 4))

        book = obj.Book()
        book.load_from_file('Book.txt')
        book_print = []
        for person in book.addrbook:
            book_print.append(person.to_string(['first', 'last', 'birthday']))
        self.assertIn(human.to_string(), book_print)
Example #3
0
    def test_find_person_by_name(self):
        human = obj.Person()
        human.create_from_name_and_birthday('John', 'Snow', obj.Date(1673, 05, 12))

        book = obj.Book()
        book.load_from_file('Book.txt')
        other_human = book.find_person_by_name('John', 'Snow')
        self.assertEqual(human.to_string(), other_human.to_string(['first', 'last', 'birthday']))

        second_other_human = book.find_person_by_name('John', 'Doe')
        self.assertNotEqual(human.to_string(), second_other_human.to_string(['first', 'last', 'birthday']))
Example #4
0
    def test_del_person(self):
        book = obj.Book()
        book.load_from_file('Book.txt')
        book.del_person('John', 'Doe')
        book_print = []
        for i in book.addrbook:
            book_print.append(i.to_string(['first', 'last', 'birthday']))

        human = obj.Person()
        human.create_from_name_and_birthday('John', 'Doe', obj.Date(1970, 11, 3))
        self.assertNotIn(human.to_string(), book_print)
Example #5
0
    def test_to_file_string(self):
        book = obj.Book()
        book.load_from_file('Book.txt')
        human = obj.Person()
        human.create_from_name_and_birthday('Ygritte', 'Wild', obj.Date(1676, 11, 28))
        human.set_middle_name('Red')
        human.set_phone('7913')
        human.set_home(['Westeros', 'North', 'Wastelands', '123', '45'])
        human.set_spouse(book.find_person_by_name('John', 'Snow'))
        human.add_kid(book.find_person_by_name('Ivan', 'Morozoff'))
        human.add_kid(book.find_person_by_name('Olga', 'Petrova'))
        human.set_number()

        addr_book = open('Book.txt')
        self.assertIn(human.to_file_string(), addr_book)
Example #6
0
    def test_fill_from_file_string(self):
        home = obj.Address()
        home.props = ['Russia', 'Moscow', 'Arbat St', '86', '101']
        work = obj.Address()
        work.props = ['Russia', 'Moscow', 'Novinsky Blvd', '22', '19']
        person = obj.Person('Ivan', 'Russian', 'Morozoff', obj.Date(1950, 8, 4), '9012', None, None, home, work)

        test_person = obj.Person()
        book = obj.Book()
        input_file = open('Book.txt')
        book.load_from_file('Book.txt')
        addr_book = []
        for string in input_file:
            test_person.fill_from_file_string(string)
            test_person.spouse_kids_fix(book)
            addr_book.append(test_person.to_string())
        self.assertIn(person.to_string(), addr_book)