Skip to content

Commit

Permalink
Revert "Finalize initial set of User Accounts tests (#39)"
Browse files Browse the repository at this point in the history
This reverts commit e5db4d0.
  • Loading branch information
Eugene Alvin Villar committed Sep 20, 2017
1 parent e5db4d0 commit 4e528a2
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 755 deletions.
2 changes: 1 addition & 1 deletion cadasta/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.1'
__version__ = '0.2.0'
79 changes: 17 additions & 62 deletions cadasta/test/account_tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,28 @@
import pytest

from ..base_test import SeleniumTestCase
from ..util import random_string

pytestmark = pytest.mark.skip

class TestLogin(SeleniumTestCase):

@pytest.fixture(autouse=True)
def get_generic_user(self, generic_user):
self.user = generic_user
class Login(SeleniumTestCase):

def test_user_can_login_by_username(self):
"""Verifies User Accounts test case #L1."""
def test_login(self):
self.open("/account/login/")
self.wd.find_css('#id_login').send_keys("cadasta-test-user-1")
self.wd.find_css("#id_password").send_keys('XYZ#qwerty')
self.wd.find_element_by_xpath('//button[@name="sign-in"]').click()
self.wd.find_elements_by_xpath(
"//span[contains(text(), 'cadasta-test-user-1')]")

self.wd.BY_LINK('Sign in').click()
self.update_form_field('login', self.user['username'])
self.update_form_field('password', self.user['password'])
self.wd.BY_NAME('sign-in').click()
self.wd.wait_for_xpath(
'//header//*[normalize-space()=""]'.format(self.user['full_name']))
self.wait_for_alert(
'Successfully signed in as {}.'.format(self.user['username']))

def test_user_can_login_by_email(self):
"""Verifies User Accounts test case #L3."""

self.wd.BY_LINK('Sign in').click()
self.update_form_field('login', self.user['email'])
self.update_form_field('password', self.user['password'])
self.wd.BY_NAME('sign-in').click()
self.wd.wait_for_xpath(
'//header//*[normalize-space()=""]'.format(self.user['full_name']))
self.wait_for_alert(
'Successfully signed in as {}.'.format(self.user['username']))

def test_user_cannot_log_in(self):
"""Verifies User Accounts test case #L2."""

self.wd.BY_LINK('Sign in').click()

msg = 'The username and/or password you specified are not correct.'

self.update_form_field('login', self.user['username'])
self.update_form_field('password', random_string())
self.wd.BY_NAME('sign-in').click()
self.wait_for_alert(msg)
self.wd.BY_LINK('Sign in')
self.wd.BY_LINK('Register')

self.update_form_field('login', random_string())
self.update_form_field('password', self.user['password'])
self.wd.BY_NAME('sign-in').click()
self.wait_for_alert(msg)
self.wd.BY_LINK('Sign in')
self.wd.BY_LINK('Register')

msg = ('The e-mail address and/or password you specified are not '
'correct.')

self.update_form_field('login', self.user['email'])
self.update_form_field('password', random_string())
self.wd.BY_NAME('sign-in').click()
self.wait_for_alert(msg)
self.wd.BY_LINK('Sign in')
self.wd.BY_LINK('Register')
class LoginFailure(SeleniumTestCase):

self.update_form_field('login', random_string() + '@cadasta.org')
self.update_form_field('password', self.user['password'])
def test_login_failure(self):
self.open("/account/login/")
self.wd.BY_NAME('login').send_keys('admin')
self.wd.BY_NAME('password').send_keys('admin')
self.wd.BY_NAME('sign-in').click()
self.wait_for_alert(msg)
self.wd.BY_LINK('Sign in')
self.wd.BY_LINK('Register')
self.wd.BY_XPATH(
'//*[@role="alert" and contains(normalize-space(),'
'"The login and/or password you specified are not correct.")]')
Loading

0 comments on commit 4e528a2

Please sign in to comment.