예제 #1
0
 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
 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!')
예제 #3
0
 def test_add_user_already_registered_in_the_library_should_return_message(
         self):
     user = User(12, 'Valentina')
     library = Library()
     library.add_user(user)
     result = library.add_user(user)
     self.assertEqual(
         result, 'User with id = 12 already registered in the library!')
예제 #4
0
 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, []')
예제 #5
0
 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!'
     )
예제 #6
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, []')
예제 #7
0
 def setUp(self):
     self.user = User(12, 'Valentina')
     self.library = Library()