def test_register_invalid_email(selenium): user_name = random_string() user_infos = { 'username': user_name, 'email': user_name, 'password': '******', 'password_conf': 'p@ssw0rd', } register(selenium, user_infos) assert selenium.current_url == f"{URL}register" nav = selenium.find_element_by_tag_name('nav').text assert "Register" in nav assert "Log in" in nav
def test_login_not_existing_user(selenium): user_name = random_string() user_infos = { 'username': user_name, 'email': f'{user_name}@example.com', 'password': '******', 'password_conf': 'p@ssw0rd', } login(selenium, user_infos, True) nav = selenium.find_element_by_tag_name('nav') nav_text = nav.text assert "Register" in nav_text assert "Log in" in nav_text errors = selenium.find_element_by_class_name('alert-danger').text assert "Invalid credentials." in errors
def test_register_password_confirmation_not_ok(selenium): user_name = random_string() user_infos = { 'username': user_name, 'email': f'{user_name}@example.com', 'password': '******', 'password_conf': 'password', } register(selenium, user_infos) assert selenium.current_url == f"{URL}register" nav = selenium.find_element_by_tag_name('nav').text assert "Register" in nav assert "Log in" in nav errors = selenium.find_element_by_class_name('alert-danger').text assert "Password and password confirmation don't match" in errors
def test_register_multiple_errors(selenium): user_name = random_string(2) user_infos = { 'username': user_name, 'email': f'{user_name}@example', 'password': '******', 'password_conf': 'pass', } register(selenium, user_infos) assert selenium.current_url == f"{URL}register" nav = selenium.find_element_by_tag_name('nav').text assert "Register" in nav assert "Log in" in nav errors = selenium.find_element_by_class_name('alert-danger').text assert "Username: 3 to 12 characters required" in errors assert "Valid email must be provided" in errors assert "Password: 8 characters required" in errors