This commit is contained in:
Oleg Podsadny 2013-06-09 13:32:01 +02:00
parent c16bd4ae07
commit c00203ba3a
9 changed files with 52 additions and 36 deletions

View File

@ -6,11 +6,13 @@ from pytest_bdd_example.dashboard.forms import LoginForm
bp = Blueprint('dashboard', __name__)
@bp.route('/')
@login_required
def index(template='dashboard.html'):
return render_template(template)
@bp.route('/login/', methods=['GET', 'POST'])
def login():
login_form = LoginForm()

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',
)

22
tests/fixtures/auth.py vendored Normal file
View File

@ -0,0 +1,22 @@
import pytest
from pytest_bdd_example.dashboard.models import User
from pytest_bdd_example.dashboard import db
from tests.helpers.random import random_string
@pytest.fixture
def password():
return 'asdasd'
@pytest.fixture
def user(password):
u = User(
username=random_string(),
password=password,
)
db.session.add(u)
db.session.commit()
return u

View File

@ -27,6 +27,11 @@ def post_the_form():
pass
@then('I should see an error message')
def should_see_error_message():
pass
@then('I shouldn\'t see an error message')
def shouldnt_see_error_message():
pass

View File

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

View File

@ -1,6 +0,0 @@
import pytest
@pytest.fixture
def password():
return 'asdasd'

View File

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

View File

8
tests/helpers/random.py Normal file
View File

@ -0,0 +1,8 @@
import random
import string
def random_string(length=20):
"""Create a random string."""
alphanums = string.ascii_lowercase + string.digits
return ''.join(random.choice(alphanums) for _ in xrange(length))