Created
July 19, 2015 21:33
-
-
Save miohtama/ef56fcf0b9f264226250 to your computer and use it in GitHub Desktop.
Splinter + py.test functional testing of Pyramid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from websauna.system.model import DBSession | |
EMAIL = "example@example.com" | |
PASSWORD = "ToholamppiMadCowz585" | |
def get_user(): | |
from websauna.system.user.models import User | |
return DBSession.query(User).get(1) | |
def test_register_email(web_server, browser, dbsession): | |
"""Register on the site and login after activation.""" | |
# Load user model | |
# registry = get_current_registry() | |
# User = registry.queryUtility(IUserClass) | |
# assert User | |
b = browser | |
b.visit(web_server) | |
b.click_link_by_text("Sign up") | |
assert b.is_element_visible_by_css("#sign-up-form") | |
b.fill("email", EMAIL) | |
b.fill("password", PASSWORD) | |
b.fill("password-confirm", PASSWORD) | |
b.find_by_name("sign_up").click() | |
assert b.is_element_visible_by_css("#waiting-for-activation") | |
# Now peek the Activation link from the database | |
user = get_user() | |
assert user.activation.code | |
activation_link = "{}/activate/{}/{}".format(web_server, user.id, user.activation.code) | |
b.visit(activation_link) | |
assert b.is_element_visible_by_css("#sign-up-complete") | |
b.fill("username", EMAIL) | |
b.fill("password", PASSWORD) | |
b.find_by_name("Log_in").click() | |
# After login we see a profile link to our profile | |
assert b.is_element_visible_by_css("#nav-logout") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment