-
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.
[qalab] extract vars_names to move JSON config
+ issue related #33
- Loading branch information
crypto netzulo
committed
Jan 5, 2018
1 parent
29c58c5
commit fb17146
Showing
9 changed files
with
289 additions
and
51 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,77 @@ | ||
# -*- coding: utf-8 -*- | ||
"""TODO: doc module""" | ||
|
||
|
||
# SETTINGS start | ||
PATH_CONFIG = 'qalab/configs' | ||
PATH_DRIVERS_MODULE = 'modules/qadrivers/' | ||
PATH_SERVER_DRIVERS = 'qalab/drivers' | ||
PATH_APKS = 'qalab/apks' | ||
WEBDRIVER_ENV_VARS = [ | ||
"-Dwebdriver.chrome.driver=", | ||
"-Dwebdriver.gecko.driver=", | ||
"-Dphantomjs.binary.path=", | ||
"-Dwebdriver.ie.driver=", | ||
"-Dwebdriver.edge.driver=", | ||
"-Dwebdriver.opera.driver=" | ||
] | ||
DRIVERS_NAMES = [ | ||
"chromedriver_32.exe", | ||
"chromedriver_64.exe", | ||
"chromedriver_32", | ||
"chromedriver_64", | ||
"firefoxdriver_32.exe", | ||
"firefoxdriver_64.exe", | ||
"firefoxdriver_32", | ||
"firefoxdriver_64", | ||
"phantomjsdriver_32.exe", | ||
"phantomjsdriver_64.exe", | ||
"phantomjsdriver_32", | ||
"phantomjsdriver_64", | ||
"iexplorerdriver_32.exe", | ||
"iexplorerdriver_64.exe", | ||
"edgedriver_32.exe", | ||
"edgedriver_64.exe", | ||
"operadriver_32.exe", | ||
"operadriver_64.exe", | ||
"operadriver_32", | ||
"operadriver_64", | ||
] | ||
MSG_UNKOWN_COMMAND = "Unknown command : {}" | ||
### COMMON | ||
# {path}/{args.server_driver}.{args.mode}.json | ||
DRIVER_CONFIG_PATH = "{}/{}.{}.json" | ||
# {path}/{args.server_driver}.{args.mode}.example.json | ||
DRIVER_CONFIG_PATH_EXAMPLE = "{}/{}.{}.example.json" | ||
### SELENIUM | ||
SELENIUM_VERSION = "3.5" | ||
SELENIUM_VERSION_BUILD = "3.5.3" | ||
SELENIUM_JAR_NAME = "selenium-server-standalone-{}.jar".format( | ||
SELENIUM_VERSION_BUILD) | ||
SELENIUM_URL = "https://selenium-release.storage.googleapis.com/{}/{}".format( | ||
SELENIUM_VERSION, SELENIUM_JAR_NAME) | ||
|
||
### SELENDROID | ||
# Selendroid , TODO: just for mode node | ||
SELENDROID_PORT = 12000 | ||
SELENDROID_SELENDROID_VERSION = '0.17.0' | ||
SELENDROID_JAR = 'selendroid-standalone-{}-with-dependencies.jar'.format( | ||
SELENDROID_SELENDROID_VERSION) | ||
SELENDROID_URL = '{}/{}/{}'.format( | ||
'https://github.com/selendroid/selendroid/releases/download', | ||
SELENDROID_SELENDROID_VERSION, | ||
SELENDROID_JAR) | ||
# Selendroid plugin, TODO: just for mode node | ||
SELENDROID_PLUGIN_JAR = 'selendroid-grid-plugin-{}.jar'.format( | ||
SELENDROID_SELENDROID_VERSION) | ||
SELENDROID_PLUGIN_URL = '{}/{}/{}'.format( | ||
'http://search.maven.org/remotecontent?filepath=io/selendroid/selendroid-grid-plugin', | ||
SELENDROID_SELENDROID_VERSION, | ||
SELENDROID_JAR) | ||
# Selenium, TODO: just for mode hub | ||
SELENDROID_SELENIUM_VERSION = "3.5.3" | ||
SELENDROID_SELENIUM_JAR = "selenium-server-standalone-{}.jar".format( | ||
SELENDROID_SELENIUM_VERSION) | ||
SELENDROID_SELENIUM_URL = "https://selenium-release.storage.googleapis.com/3.5/{}".format( | ||
SELENDROID_SELENIUM_JAR) | ||
# SETTINGS end |
Empty file.
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,19 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
"""TODO: doc module""" | ||
|
||
|
||
from qalab.core.server_driver_base import ServerDriverBase | ||
|
||
|
||
class ServerDriverSelendroid(ServerDriverBase): | ||
"""TODO: doc class""" | ||
|
||
_server_driver = 'selendroid' | ||
|
||
def __init__(self, mode): | ||
"""TODO: doc method""" | ||
super(ServerDriverSelendroid, self).__init__(mode) | ||
|
||
def install(self): | ||
self._configure(self._server_driver) |
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,19 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
"""TODO: doc module""" | ||
|
||
|
||
from qalab.core.server_driver_base import ServerDriverBase | ||
|
||
|
||
class ServerDriverAppium(ServerDriverBase): | ||
"""TODO: doc class""" | ||
|
||
_server_driver = 'appium' | ||
|
||
def __init__(self): | ||
"""TODO: doc method""" | ||
super(ServerDriverAppium, self).__init__() | ||
|
||
def install(self): | ||
self._configure(self._server_driver) |
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,53 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
"""TODO: doc module""" | ||
|
||
|
||
import qalab.configs.settings as SETTINGS | ||
import shutil | ||
|
||
|
||
class ServerDriverBase(object): | ||
"""TODO: doc class""" | ||
|
||
_mode = None | ||
_config_src = None | ||
_config_dst = None | ||
_server_driver = 'base' | ||
|
||
|
||
def __init__(self, mode): | ||
"""TODO: doc method""" | ||
if mode is None: | ||
raise Exception("param 'mode' can't be None") | ||
if mode not in ['hub', 'node']: | ||
raise Exception('Select valid mode, values are: [hub, node]') | ||
self._mode = mode | ||
_config_path_example = SETTINGS.DRIVER_CONFIG_PATH_EXAMPLE | ||
_config_path = SETTINGS.DRIVER_CONFIG_PATH | ||
|
||
def _configure(self, server_driver): | ||
""" | ||
Just copy settings from example file | ||
from: {server_driver}.{args.mode}.example.json | ||
to: {server_driver}.{args.mode}.json | ||
""" | ||
if server_driver not in ['selenium', 'selendroid', 'appium']: | ||
raise Exception( | ||
'Select valid mode, values are: [selenium, selendroid, appium]' | ||
) | ||
self._config_path_example = self._config_path_example.format( | ||
SETTINGS.PATH_CONFIG, server_driver, self._mode) | ||
self._config_path = self._config_path.format( | ||
SETTINGS.PATH_CONFIG, server_driver, self._mode) | ||
shutil.copy2( | ||
self._config_path_example, | ||
self._config_path) | ||
|
||
def install(self): | ||
"""Installation process""" | ||
raise NotImplementedError('need to be overrided on inherit classes') | ||
|
||
def start(self): | ||
"""Installation process""" | ||
raise NotImplementedError('need to be overrided on inherit classes') |
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,47 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
"""TODO: doc module""" | ||
|
||
|
||
from qalab.core.server_driver_base import ServerDriverBase | ||
import qalab.configs.settings as SETTINGS | ||
|
||
|
||
class ServerDriverSelenium(ServerDriverBase): | ||
"""TODO: doc class""" | ||
|
||
_server_driver = 'selenium' | ||
_drivers_abspath = None | ||
|
||
|
||
def __init__(self, mode): | ||
"""TODO: doc method""" | ||
super(ServerDriverSelenium, self).__init__(mode) | ||
self._drivers_abspath = self.get_abspaths() | ||
|
||
def install(self): | ||
self._configure(self._server_driver) | ||
|
||
def get_abspaths(self): | ||
"""TODO: doc method""" | ||
drivers_abspath = [] | ||
for driver_name in SETTINGS.DRIVERS_NAMES: | ||
webdriver_var_name = None | ||
if driver_name.startswith("chrome"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[0] | ||
if driver_name.startswith("firefox"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[1] | ||
if driver_name.startswith("phantomjs"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[2] | ||
if driver_name.startswith("iexplorer"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[3] | ||
if driver_name.startswith("edge"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[4] | ||
if driver_name.startswith("opera"): | ||
webdriver_var_name = SETTINGS.WEBDRIVER_ENV_VARS[5] | ||
# Get absolute path for driver_name | ||
drivers_abspath.append("{}{}{}".format( | ||
webdriver_var_name, | ||
SETTINGS.PATH_DRIVERS_MODULE, | ||
driver_name)) | ||
return drivers_abspath |
Oops, something went wrong.