test fixed
This commit is contained in:
parent
b971873349
commit
5c6b8cca0e
|
@ -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',
|
||||
)
|
|
@ -14,7 +14,7 @@ def password():
|
|||
@pytest.fixture
|
||||
def user(password):
|
||||
u = User(
|
||||
username=random_string(),
|
||||
username=u'{0}@example.com'.format(random_string(7)),
|
||||
password=password,
|
||||
)
|
||||
db.session.add(u)
|
||||
|
|
|
@ -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',
|
||||
)
|
|
@ -1,6 +1,13 @@
|
|||
import pytest
|
||||
from pytest_bdd import scenario, given, when, then
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pytestbdd_close_browser():
|
||||
"""Close browser fixture."""
|
||||
return False
|
||||
|
||||
|
||||
test_successful_login = scenario(
|
||||
'auth/admin_login.feature',
|
||||
'Successful login',
|
||||
|
@ -9,22 +16,23 @@ test_successful_login = scenario(
|
|||
|
||||
@given('I\'m an admin user')
|
||||
def admin_user(user):
|
||||
pass
|
||||
return user
|
||||
|
||||
|
||||
@when('I go to the admin login page')
|
||||
def go_to_login_page(browser):
|
||||
pass
|
||||
browser.visit('http://127.0.0.1:5000')
|
||||
|
||||
|
||||
@when('I fill in the login credentials')
|
||||
def fill_in_login_credentials():
|
||||
pass
|
||||
def fill_in_login_credentials(browser, user, password):
|
||||
browser.fill('email', user.username)
|
||||
browser.fill('password', password)
|
||||
|
||||
|
||||
@when('I post the form')
|
||||
def post_the_form():
|
||||
pass
|
||||
def post_the_form(browser):
|
||||
browser.find_by_css('button[type=submit]').first.click()
|
||||
|
||||
|
||||
@then('I should see an error message')
|
||||
|
@ -42,10 +50,10 @@ def should_see_dashboard():
|
|||
pass
|
||||
|
||||
|
||||
test_successful_login = scenario(
|
||||
'auth/admin_login.feature',
|
||||
'Unsuccessful login',
|
||||
)
|
||||
# test_successful_login = scenario(
|
||||
# 'auth/admin_login.feature',
|
||||
# 'Unsuccessful login',
|
||||
# )
|
||||
|
||||
|
||||
@when('I fill in wrong login credentials')
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
|
|
Loading…
Reference in New Issue