test fixed

This commit is contained in:
Oleg Podsadny 2013-06-15 01:21:39 +02:00
parent b971873349
commit 5c6b8cca0e
9 changed files with 36 additions and 26 deletions

View File

@ -1,15 +0,0 @@
import os
import pytest
import pytest_bdd_example as main_pkg
from tests.fixtures.auth import *
@pytest.fixture
def pytestbdd_feature_base_dir():
"""Feature files base directory."""
return os.path.join(
os.path.dirname(
os.path.dirname(main_pkg.__file__)
), 'features',
)

View File

@ -14,7 +14,7 @@ def password():
@pytest.fixture @pytest.fixture
def user(password): def user(password):
u = User( u = User(
username=random_string(), username=u'{0}@example.com'.format(random_string(7)),
password=password, password=password,
) )
db.session.add(u) db.session.add(u)

View File

@ -0,0 +1,15 @@
import os
import pytest
import pytest_bdd_example as main_pkg
from tests.fixtures.auth import *
@pytest.fixture
def pytestbdd_feature_base_dir():
"""Feature files base directory."""
return os.path.join(
os.path.dirname(
os.path.dirname(main_pkg.__file__)
), 'features',
)

View File

@ -1,6 +1,13 @@
import pytest
from pytest_bdd import scenario, given, when, then from pytest_bdd import scenario, given, when, then
@pytest.fixture
def pytestbdd_close_browser():
"""Close browser fixture."""
return False
test_successful_login = scenario( test_successful_login = scenario(
'auth/admin_login.feature', 'auth/admin_login.feature',
'Successful login', 'Successful login',
@ -9,22 +16,23 @@ test_successful_login = scenario(
@given('I\'m an admin user') @given('I\'m an admin user')
def admin_user(user): def admin_user(user):
pass return user
@when('I go to the admin login page') @when('I go to the admin login page')
def go_to_login_page(browser): def go_to_login_page(browser):
pass browser.visit('http://127.0.0.1:5000')
@when('I fill in the login credentials') @when('I fill in the login credentials')
def fill_in_login_credentials(): def fill_in_login_credentials(browser, user, password):
pass browser.fill('email', user.username)
browser.fill('password', password)
@when('I post the form') @when('I post the form')
def post_the_form(): def post_the_form(browser):
pass browser.find_by_css('button[type=submit]').first.click()
@then('I should see an error message') @then('I should see an error message')
@ -42,10 +50,10 @@ def should_see_dashboard():
pass pass
test_successful_login = scenario( # test_successful_login = scenario(
'auth/admin_login.feature', # 'auth/admin_login.feature',
'Unsuccessful login', # 'Unsuccessful login',
) # )
@when('I fill in wrong login credentials') @when('I fill in wrong login credentials')

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import
import random import random
import string import string