-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5 from kieras/develop
Gapi2 login, Headless mode, Local config file support, debug messages and other improvements
- Loading branch information
Showing
6 changed files
with
199 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
# |_| \__,_|_| \__,_|_|\_\___|\___|\__| | ||
|
||
|
||
__version__ = '0.0.11' | ||
__version__ = '0.0.12' |
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 |
---|---|---|
@@ -1,17 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
from lettuce import step, world | ||
from auth import LoginPage | ||
from parakeet.lettuce_logger import LOG | ||
|
||
|
||
@step(u'.* the logged user is "([^"]*)"') | ||
def login(step, user_name): | ||
# If it is already logged do not attempt to login | ||
""" | ||
If it is already logged do not attempt to login | ||
:param step: | ||
:param user_name: | ||
:return: | ||
""" | ||
if world.cfg['system_page_title'] not in world.browser.selenium.title: | ||
email = world.users[user_name]['email'] | ||
password = world.users[user_name]['password'] | ||
LoginPage(world.browser, world.cfg['system_page_title'])\ | ||
.fill_email(email)\ | ||
.click_next()\ | ||
.fill_password(password)\ | ||
.login()\ | ||
.redirect_to_home() | ||
LOG.debug(world.cfg.get('login_provider','missing login provider')) | ||
if world.cfg['login_provider'] == 'google_oauth': | ||
google_oauth(user_name) | ||
elif world.cfg['login_provider'] == 'google_oauth_gapi2': | ||
google_oauth_gapi2(user_name) | ||
LoginPage(world.browser, world.cfg['system_page_title']).redirect_to_home() | ||
|
||
|
||
def google_oauth(user_name): | ||
""" | ||
Default login with old GAPI Google Oauth version | ||
:param user_name: | ||
:return: | ||
""" | ||
email = world.users[user_name]['email'] | ||
password = world.users[user_name]['password'] | ||
LoginPage(world.browser, world.cfg['system_page_title'])\ | ||
.fill_email(email)\ | ||
.click_next()\ | ||
.fill_password(password)\ | ||
.login() | ||
|
||
|
||
def google_oauth_gapi2(user_name): | ||
""" | ||
Login with personalized GAPI2 oauth version | ||
:return: | ||
""" | ||
LoginPage(world.browser, world.cfg['system_page_title'])\ | ||
.set_window()\ | ||
.click_sign_in()\ | ||
.switch_windows_after() | ||
google_oauth(user_name) | ||
LoginPage(world.browser, world.cfg['system_page_title'])\ | ||
.switch_windows_before() |
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,51 @@ | ||
import logging | ||
import sys | ||
from colorlog import ColoredFormatter | ||
|
||
log_level = {'INFO': logging.INFO, | ||
'WARNING': logging.WARNING, | ||
'DEBUG': logging.DEBUG, | ||
'ERROR': logging.ERROR} | ||
|
||
APP_LOGGER = 'google.tests.e2e' | ||
|
||
formatter = ColoredFormatter( | ||
"%(green)s%(asctime)s - %(name)s -%(reset)s %(log_color)s%(levelname)-8s%(reset)s" | ||
" - %(white)s%(message)s", | ||
datefmt=None, | ||
reset=True, | ||
log_colors={ | ||
'DEBUG': 'cyan', | ||
'INFO': 'green', | ||
'WARNING': 'yellow', | ||
'ERROR': 'red', | ||
'CRITICAL': 'red', | ||
} | ||
) | ||
|
||
|
||
def init_logs(level='INFO', logger=None): | ||
""" | ||
Setup the logs inside of the tests. | ||
:param level: | ||
:param logger: | ||
:return: | ||
""" | ||
handler = logging.getLogger(logger) | ||
_level = log_level.get(level, logging.INFO) | ||
handler.setLevel(_level) | ||
ch = logging.StreamHandler(sys.stdout) | ||
ch.setLevel(_level) | ||
ch.setFormatter(formatter) | ||
handler.addHandler(ch) | ||
|
||
|
||
def get_logger(): | ||
""" | ||
Return the default logger. | ||
:return: | ||
""" | ||
return logging.getLogger(APP_LOGGER) | ||
|
||
|
||
LOG = get_logger() |
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