コード例 #1
0
ファイル: __init__.py プロジェクト: Mr-Sims/SoftUni_PY
 def test_change_username_method_with_user_id_not_included_in_library_records_should_return_message(
         self):
     v = User(12, 'Valentina')
     p = User(13, 'Peter')
     library = Library()
     library.add_user(v)
     result = library.change_username(13, 'George')
     self.assertEqual(result, 'There is no user with id = 13!')
コード例 #2
0
ファイル: __init__.py プロジェクト: Mr-Sims/SoftUni_PY
 def test_change_username_method_with_valid_data_should_return_message_and_update_library_records(
         self):
     v = User(12, 'Valentina')
     p = User(13, 'Peter')
     library = Library()
     library.add_user(v)
     result = library.change_username(12, 'Violeta')
     self.assertEqual(
         result, 'Username successfully changed to: Violeta for userid: 12')
     self.assertEqual(library.user_records[0].__str__(), '12, Violeta, []')
コード例 #3
0
ファイル: __init__.py プロジェクト: Mr-Sims/SoftUni_PY
 def test_change_username_method_with_user_id_included_in_library_records_but_provided_new_username_is_the_same_should_return_message(
         self):
     v = User(12, 'Valentina')
     p = User(13, 'Peter')
     library = Library()
     library.add_user(v)
     result = library.change_username(12, 'Valentina')
     self.assertEqual(
         result,
         'Please check again the provided username - it should be different than the username used so far!'
     )
コード例 #4
0
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)