Beispiel #1
0
 def test_remove_user_method_with_valid_data_should_update_library_records_properly(
         self):
     user = User(12, 'Valentina')
     library = Library()
     library.add_user(user)
     library.add_user(User(13, 'Peter'))
     library.remove_user(user)
     self.assertEqual(library.user_records[0].__str__(), '13, Peter, []')
Beispiel #2
0
 def test_remove_user_method_with_user_not_registered_should_return_message(
         self):
     v = User(12, 'Valentina')
     p = User(13, 'Peter')
     library = Library()
     library.add_user(v)
     result = library.remove_user(p)
     self.assertEqual(result, 'We could not find such user to remove!')
from project.library import Library
from project.user import User

user = User(12, 'Peter')
library = Library()
library.add_user(user)
print(library.add_user(user))
library.remove_user(user)
print(library.remove_user(user))
library.add_user(user)
print(library.change_username(2, 'Igor'))
print(library.change_username(12, 'Peter'))
print(library.change_username(12, 'George'))

[
    print(
        f'{user_record.user_id}, {user_record.username}, {user_record.books}')
    for user_record in library.user_records
]
library.books_available.update({
    'J.K.Rowling': [
        'The Chamber of Secrets', 'The Prisoner of Azkaban',
        'The Goblet of Fire', 'The Order of the Phoenix',
        'The Half-Blood Prince', 'The Deathly Hallows'
    ]
})

user.get_book('J.K.Rowling', 'The Deathly Hallows', 17, library)
print(library.books_available)
print(library.rented_books)
print(user.books)