fixtures
This commit is contained in:
parent
c16bd4ae07
commit
c00203ba3a
|
@ -6,11 +6,13 @@ from pytest_bdd_example.dashboard.forms import LoginForm
|
||||||
|
|
||||||
bp = Blueprint('dashboard', __name__)
|
bp = Blueprint('dashboard', __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
@login_required
|
@login_required
|
||||||
def index(template='dashboard.html'):
|
def index(template='dashboard.html'):
|
||||||
return render_template(template)
|
return render_template(template)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/login/', methods=['GET', 'POST'])
|
@bp.route('/login/', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
login_form = LoginForm()
|
login_form = LoginForm()
|
||||||
|
|
|
@ -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',
|
||||||
|
)
|
|
@ -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
|
|
@ -27,6 +27,11 @@ def post_the_form():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@then('I should see an error message')
|
||||||
|
def should_see_error_message():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@then('I shouldn\'t see an error message')
|
@then('I shouldn\'t see an error message')
|
||||||
def shouldnt_see_error_message():
|
def shouldnt_see_error_message():
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -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',
|
|
||||||
)
|
|
|
@ -1,6 +0,0 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def password():
|
|
||||||
return 'asdasd'
|
|
|
@ -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',
|
|
||||||
)
|
|
|
@ -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))
|
Loading…
Reference in New Issue