def test_valid_login(self): """If existing, valid user details are entered on the login page, the user is logged in.""" s = self.selenium create_user('LegitLarry', password='******') login(s, self.live_server_url, 'LegitLarry', 'PurePassword') self.assertEqual(s.current_url, self.live_server_url + reverse('mentor:index'))
def test_invalid_login(self): """If an incorrect username or password is entered, the user will not be logged in.""" s = self.selenium create_user('LawfulLaurence', password='******') # Incorrect password: login(s, self.live_server_url, 'LawfulLaurence', 'IncorrectPasswordOops') assert 'Please enter a correct username and password.' in s.page_source # Non-existent username: login(s, self.live_server_url, 'UnlawfulUrsula', 'IncorrectPasswordOops') assert 'Please enter a correct username and password.' in s.page_source
def test_invalid_signup(self): """ If invalid values are entered for signup form fields, the user is redirected back to the signup page and errors are displayed.""" s = self.selenium # Create a user with username Clarence: create_user('Clarence') # Username blank: self.sign_up('', '*****@*****.**', 'ExcellentPassword') # (Don't know how to test for JavaScript validation messages, this is default HTML behaviour anyway) assert 'signup' in s.current_url # Existing username: self.sign_up('Clarence', '*****@*****.**', 'ExcellentPassword') assert 'A user with that username already exists.' in s.page_source # Blank email: self.sign_up('Eustace', '', 'ExquisitePassword') assert 'signup' in s.current_url # Invalid email: self.sign_up('Eustace', 'thisaintan@email', 'ExquisitePassword') assert 'signup' in s.current_url # Blank password: self.sign_up('Eustace', '*****@*****.**', '') assert 'signup' in s.current_url # Password too short: self.sign_up('Eustace', '*****@*****.**', 'ttt') assert 'This password is too short. It must contain at least 8 characters.' in s.page_source # Password entirely numeric: self.sign_up('Eustace', '*****@*****.**', '888888888') assert 'This password is entirely numeric.' in s.page_source
def test_logout(self): """The user is logged out once the logout link is selected in the navbar.""" s = self.selenium user = create_user('DeterminedDemetrius', password="******") game = create_game('Super Smash Bros. Melee', 'Melee') login(s, self.live_server_url, user.username, "I'llNeverRememberThisOne") s.find_element_by_id('logout').click() assert 'Log out' not in s.page_source assert 'Select a game:' in s.page_source # Attempt to go to character overlay, which you can only access whilst logged in: s.get(self.live_server_url + reverse('mentor:char_overlay', args=[game.id])) assert 'login' in s.current_url
def test_get_game(self): """Returns the Game object related to the character in the given UserCharacter.""" game, char = create_game_and_char('Street Fighter V', '', 'Ryu') user = create_user('Clive') user_char = create_user_char(user, char, False) self.assertEqual(user_char.get_game(), game)
def setUp(self): super(CharOverlayTests, self).setUp() self.game = create_game('Super Smash Bros. Ultimate', 'Smash Ultimate') self.user = create_user('Clive', password='******')