From 314dc05278024871ffef6bb450d9898151ceddc0 Mon Sep 17 00:00:00 2001 From: Oleg Podsadny Date: Thu, 6 Jun 2013 23:22:49 +0200 Subject: [PATCH] started tests --- .../admin_login.feature} | 4 +- tests/fixtures/README.txt | 1 + tests/fixtures/__init__.py | 0 tests/functional/__init__.py | 0 tests/functional/admin/__init__.py | 0 tests/functional/admin/auth/__init__.py | 0 .../functional/admin/auth/test_auth_login.py | 48 +++++++++++++++++++ tests/functional/admin/conftest.py | 15 ++++++ tests/functional/admin/fixtures/__init__.py | 0 tests/functional/admin/fixtures/auth.py | 6 +++ tests/functional/conftest.py | 15 ++++++ tests/functional/shop/__init__.py | 0 tests/unit/__init__.py | 0 13 files changed, 87 insertions(+), 2 deletions(-) rename features/{admin/login.feature => auth/admin_login.feature} (81%) create mode 100644 tests/fixtures/README.txt create mode 100644 tests/fixtures/__init__.py create mode 100644 tests/functional/__init__.py create mode 100644 tests/functional/admin/__init__.py create mode 100644 tests/functional/admin/auth/__init__.py create mode 100644 tests/functional/admin/auth/test_auth_login.py create mode 100644 tests/functional/admin/conftest.py create mode 100644 tests/functional/admin/fixtures/__init__.py create mode 100644 tests/functional/admin/fixtures/auth.py create mode 100644 tests/functional/conftest.py create mode 100644 tests/functional/shop/__init__.py create mode 100644 tests/unit/__init__.py diff --git a/features/admin/login.feature b/features/auth/admin_login.feature similarity index 81% rename from features/admin/login.feature rename to features/auth/admin_login.feature index 3311345..1f3e4e7 100644 --- a/features/admin/login.feature +++ b/features/auth/admin_login.feature @@ -1,7 +1,7 @@ Scenario: Successful login Given I'm an admin user - When I open the login page + When I go to the admin login page And I fill in the login credentials And I post the form @@ -11,7 +11,7 @@ Scenario: Successful login Scenario: Unsuccessful login - When I open the login page + When I go to the admin login page And I fill in wrong login credentials And I post the form diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt new file mode 100644 index 0000000..b880671 --- /dev/null +++ b/tests/fixtures/README.txt @@ -0,0 +1 @@ +This should contain fixtures that are used in both functional and unit tests diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/admin/__init__.py b/tests/functional/admin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/admin/auth/__init__.py b/tests/functional/admin/auth/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/admin/auth/test_auth_login.py b/tests/functional/admin/auth/test_auth_login.py new file mode 100644 index 0000000..0919e69 --- /dev/null +++ b/tests/functional/admin/auth/test_auth_login.py @@ -0,0 +1,48 @@ +from pytest_bdd import scenario, given, when, then + + +test_successful_login = scenario( + 'auth/admin_login.feature', + 'Successful login', +) + + +@given('I\'m an admin user') +def admin_user(user): + pass + + +@when('I go to the admin login page') +def go_to_login_page(browser): + pass + + +@when('I fill in the login credentials') +def fill_in_login_credentials(): + pass + + +@when('I post the form') +def post_the_form(): + pass + + +@then('I shouldn\'t see an error message') +def shouldnt_see_error_message(): + pass + + +@then('I should see the Dashboard page') +def should_see_dashboard(): + pass + + +test_successful_login = scenario( + 'auth/admin_login.feature', + 'Unsuccessful login', +) + + +@when('I fill in wrong login credentials') +def fill_in_wrong_credentials(): + pass diff --git a/tests/functional/admin/conftest.py b/tests/functional/admin/conftest.py new file mode 100644 index 0000000..6790c01 --- /dev/null +++ b/tests/functional/admin/conftest.py @@ -0,0 +1,15 @@ +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', + ) diff --git a/tests/functional/admin/fixtures/__init__.py b/tests/functional/admin/fixtures/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/admin/fixtures/auth.py b/tests/functional/admin/fixtures/auth.py new file mode 100644 index 0000000..5085e04 --- /dev/null +++ b/tests/functional/admin/fixtures/auth.py @@ -0,0 +1,6 @@ +import pytest + + +@pytest.fixture +def password(): + return 'asdasd' diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py new file mode 100644 index 0000000..98b2989 --- /dev/null +++ b/tests/functional/conftest.py @@ -0,0 +1,15 @@ +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', + ) diff --git a/tests/functional/shop/__init__.py b/tests/functional/shop/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29