-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from mes-2016-1/behave_acceptance_tests
Behave acceptance tests
- Loading branch information
Showing
12 changed files
with
405 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from selenium import webdriver | ||
|
||
|
||
def before_feature(context, feature): | ||
context.driver = webdriver.Firefox() | ||
context.driver.set_window_size(1000, 600) | ||
context.driver.implicitly_wait(5) | ||
|
||
|
||
def after_feature(context, feature): | ||
context.driver.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
Feature: User Profile Edition | ||
In order to update my personal information | ||
As an User | ||
I want to be able to edit my profile | ||
|
||
Background: | ||
Given I am logged in as "john" | ||
|
||
Scenario: Edit profile without required information | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I click in "Edit Profile" | ||
When I fill " " in "id_first_name" field | ||
When I fill " " in "id_last_name" field | ||
When I click in "Update" button | ||
Then The field "id_first_name" should have an error | ||
Then The field "id_last_name" should have an error | ||
|
||
Scenario: Edit profile with valid information | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I click in "Edit Profile" | ||
When I fill "John" in "id_first_name" field | ||
When I fill "McClaine" in "id_last_name" field | ||
When I fill "Die Hard" in "id_institution" field | ||
When I fill "police officer" in "id_role" field | ||
When I fill "diehard.com" in "id_webpage" field | ||
When I fill "I am tough." in "id_bio" field | ||
When I click in "Update" button | ||
Then I should see "John McClaine" in "user-profile" | ||
Then I should see "Die Hard" in "user-profile" | ||
Then I should see "police officer" in "user-profile" | ||
Then I should see "I am tough." in "user-profile" | ||
When I click in "Edit Profile" | ||
Then I should see "diehard.com" in "id_webpage" | ||
|
||
Scenario: Change password with wrong current password | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I click in "Edit Profile" | ||
When I click in "Change Password" | ||
When I fill "wrong" in "id_old_password" field | ||
When I fill "newpassword" in "id_new_password1" field | ||
When I fill "newpassword" in "id_new_password2" field | ||
When I click in "Change my password" button | ||
Then The field "id_old_password" should have an error | ||
|
||
Scenario: Change password with wrong password confirmation | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I click in "Edit Profile" | ||
When I click in "Change Password" | ||
When I fill "john" in "id_old_password" field | ||
When I fill "newpassword" in "id_new_password1" field | ||
When I fill "differentpassword" in "id_new_password2" field | ||
When I click in "Change my password" button | ||
Then The field "id_new_password2" should have an error | ||
|
||
Scenario: Change password with success | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I click in "Edit Profile" | ||
When I click in "Change Password" | ||
When I fill "john" in "id_old_password" field | ||
When I fill "newpassword" in "id_new_password1" field | ||
When I fill "newpassword" in "id_new_password2" field | ||
When I click in "Change my password" button | ||
When I open the user menu | ||
When I click in "My Profile" | ||
When I open the user menu | ||
When I click in "Logout" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "john" in "id_username" field | ||
When I fill "newpassword" in "id_password" field | ||
When I click in "Acesso " | ||
When I click in "Login" button | ||
Then The browser URL should be "/dashboard" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from colab.accounts.models import User | ||
from behave import given, when | ||
|
||
|
||
@given(u'The user "{username}" with the password "{password}" is "{status}"') | ||
def create_user(context, username, password, status): | ||
user = User() | ||
user.username = username | ||
user.set_password(password) | ||
user.email = "usertest@colab.com.br" | ||
user.id = 1 | ||
user.first_name = "USERtestCoLaB" | ||
user.last_name = "COLAB" | ||
user.needs_update = False | ||
if status == "active": | ||
user.is_active = True | ||
else: | ||
user.is_active = False | ||
user.save() | ||
|
||
|
||
@given(u'I am logged in as "{username}"') | ||
def step_impl(context, username): | ||
context.execute_steps(''' | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
Given The user "%s" with the password "%s" is "%s" | ||
When I fill "%s" in "id_username" field | ||
When I fill "%s" in "id_password" field | ||
When I click in "Login" button | ||
''' % (username, username, 'active', username, username)) | ||
|
||
|
||
@when(u'I open the user menu') | ||
def step_impl(context): | ||
dropdown = context.driver.find_element_by_id('user-menu') | ||
dropdown.find_element_by_xpath('.//a').click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from selenium.webdriver.common.keys import Keys | ||
from behave import when, then | ||
|
||
|
||
@when(u'I access the URL "{url}"') | ||
def step_impl(context, url): | ||
context.driver.get(context.base_url + "/") | ||
|
||
|
||
@when(u'I click in "{link}"') | ||
def step_impl(context, link): | ||
context.driver.find_element_by_xpath("//a[contains(., '%s')]" % | ||
link).click() | ||
|
||
|
||
@when(u'I click in "{button_value}" button') | ||
def step_impl(context, button_value): | ||
context.driver.find_element_by_xpath( | ||
"//input[@value='%s']|//button[.='%s']" % | ||
(button_value, button_value)).click() | ||
|
||
|
||
@when(u'I fill "{text}" in "{field_id}" field') | ||
def step_impl(context, text, field_id): | ||
field = context.driver.find_element_by_id(field_id) | ||
field.clear() | ||
field.send_keys(text) | ||
|
||
|
||
@when(u'I fill "{text}" in "{field_id}" field and hit enter') | ||
def step_impl(context, text, field_id): | ||
field = context.driver.find_element_by_id(field_id) | ||
field.clear() | ||
field.send_keys(text) | ||
field.send_keys(Keys.RETURN) | ||
|
||
|
||
@then(u'The field "{field_id}" should have an error') | ||
def step_impl(context, field_id): | ||
field = context.driver.find_element_by_id(field_id) | ||
container = field.find_element_by_xpath('..') | ||
classes = container.get_attribute('class') | ||
assert 'has-error' in classes | ||
|
||
|
||
@then(u'I should see "{content}" in "{element_id}"') | ||
def step_impl(context, content, element_id): | ||
element = context.driver.find_element_by_id(element_id) | ||
assert (content in element.text) or \ | ||
(content in element.get_attribute("value")) | ||
|
||
|
||
@then(u'The browser URL should be "{url}"') | ||
def step_impl(context, url): | ||
assert context.driver.current_url.endswith(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
Feature: User sign in | ||
In order to be able to access the system funcionalities | ||
As an User | ||
I want to be able to sign in | ||
|
||
# Valid scenarios | ||
|
||
Scenario: Clicking the login button and displaying login page | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
Then The browser URL should be "/account/login" | ||
|
||
Scenario: Sign in with a valid user | ||
Given The user "colabtest" with the password "colabtest" is "active" | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_username" field | ||
When I fill "colabtest" in "id_password" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/dashboard" | ||
|
||
Scenario: Sign in with a valid user by hitting ENTER | ||
Given The user "colabtest" with the password "colabtest" is "active" | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_username" field | ||
When I fill "colabtest" in "id_password" field and hit enter | ||
Then The browser URL should be "/dashboard" | ||
|
||
Scenario: Sign in with a valid user and displaying user profile | ||
Given The user "colabtest" with the password "colabtest" is "active" | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_username" field | ||
When I fill "colabtest" in "id_password" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/dashboard" | ||
When I open the user menu | ||
Then I should see "USERtestCoLaB COLAB" in "user-menu" | ||
Then I should see "usertest@colab.com.br" in "user-menu" | ||
|
||
|
||
# Invalid scenarios | ||
|
||
Scenario: Sign in with an unregistered user | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "unregistered" in "id_username" field | ||
When I fill "any" in "id_password" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/account/login" | ||
Then I should see "Please correct the error below and try again" in "main-content" | ||
|
||
Scenario: Sign in with a inactive user | ||
Given The user "colabtest" with the password "colabtest" is "inactive" | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_username" field | ||
When I fill "colabtest" in "id_password" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/account/login" | ||
Then I should see "This account is inactive" in "main-content" | ||
|
||
Scenario: Sign in with no user information given | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I click in "Login" button | ||
Then The browser URL should be "/account/login" | ||
Then The field "id_username" should have an error | ||
Then The field "id_password" should have an error | ||
|
||
Scenario: Sign in with no password given | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_username" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/account/login" | ||
Then The field "id_password" should have an error | ||
|
||
Scenario: Sign in with no username given | ||
When I access the URL "/" | ||
When I click in "Acesso " | ||
When I click in "Login" | ||
When I fill "colabtest" in "id_password" field | ||
When I click in "Login" button | ||
Then The browser URL should be "/account/login" | ||
Then The field "id_username" should have an error | ||
|
Oops, something went wrong.