コード例 #1
0
ファイル: config.py プロジェクト: migueloop/qautobots
def get_db_config(database):
    """Get config for database connection

    :param str database: The type of database to connect to. Same as
        :func:`remunerator.stored_procedures.get_db_connection`
        :attr:`database` argument

    :returns: :obj:`dict` containing the connection information needed to
        connect to postgres using :mod:`psycopg2`.

    """
    config = get_config()

    user = config['connections'][database]['user']
    database_config = config['guitests']['postgresql']['users']

    if user not in database_config:
        raise KeyError('User "{0}" does not exist in the config'.format(user))

    new_config = {
        'host': database_config[user]['host'],
        'user': user,
        'password': database_config[user]['password'],
        'port': database_config[user]['port'],
    }
    return new_config
コード例 #2
0
ファイル: helpers.py プロジェクト: migueloop/qautobots
def get_selenium_url():
    """Return a URL where the selenium grid can be found."""
    config = get_config()['selenium']

    profile = ''
    if config['hub']['provider'] == 'sauce':
        profile = "{user}:{key}@".format(**config['sauce'])

    command_executor = "http://{0}{url}:{port}/wd/hub".format(
        profile, **config['hub'])
    return str(command_executor)
コード例 #3
0
ファイル: config.py プロジェクト: migueloop/qautobots
def get_api_config(api):
    """Get config for api connection

    :param str api: The API to connect to.
    :returns: :obj:`dict` containting the connection information needed to the
        specified API with :mode:`requests`.

    """
    config = get_config()
    api_config = config['apis'][api]
    return api_config
コード例 #4
0
ファイル: helpers.py プロジェクト: chasepilon/qautobots
def get_selenium_url():
    """Return a URL where the selenium grid can be found."""
    config = get_config()['selenium']

    profile = ''
    if config['hub']['provider'] == 'sauce':
        profile = "{user}:{key}@".format(**config['sauce'])

    command_executor = "http://{0}{url}:{port}/wd/hub".format(
        profile, **config['hub'])
    return str(command_executor)
コード例 #5
0
ファイル: config.py プロジェクト: migueloop/qautobots
def get_cookie_support():
    """Get cookies configuration from config file

    Cookie support is a cookie that will be sent to browser
    indicating that the browser is supporting cookie from
    application.
    """
    config = get_config()
    cookies = config['cookie_support']
    cookies['domain'] = get_application_settings()['host']
    return cookies
コード例 #6
0
ファイル: helpers.py プロジェクト: migueloop/qautobots
def get_desired_capabilities():
    """Return an object that specifies the desired capabilities.

    Read environment variables that specify how the Selenium test
    should be run. Return a dictionary representation of those values.

    """
    config = get_config()
    browser = config['selenium']['browser']
    desired_capabilities = getattr(webdriver.DesiredCapabilities, browser)
    desired_capabilities = _merge_dicts(desired_capabilities,
                                        config['selenium'])
    return desired_capabilities
コード例 #7
0
ファイル: helpers.py プロジェクト: chasepilon/qautobots
def get_desired_capabilities():
    """Return an object that specifies the desired capabilities.

    Read environment variables that specify how the Selenium test
    should be run. Return a dictionary representation of those values.

    """
    config = get_config()
    browser = config['selenium']['browser']
    desired_capabilities = getattr(
        webdriver.DesiredCapabilities, browser)
    desired_capabilities = _merge_dicts(
        desired_capabilities, config['selenium'])
    return desired_capabilities
コード例 #8
0
ファイル: email.py プロジェクト: migueloop/qautobots
def read_email(subject, deleted=True):
    """Read Email from server and delete it"""
    config = get_config()['email']
    mail = imaplib.IMAP4_SSL(config['incoming'])
    mail.login(config['username'], config['password'])
    mail.select(config['folder'])
    search_result = mail.search(None, '(SUBJECT "{0}")'.format(subject))
    mail_id = search_result[1][0]
    if mail_id == '':
        email_body = None
    else:
        email_content = mail.fetch(mail_id, '(BODY.PEEK[TEXT])')
        email_body = email_content[1][0][1]
        if deleted:
            mail.store(mail_id, '+FLAGS', '(\Deleted)')
            mail.expunge()
    mail.logout()
    return email_body
コード例 #9
0
ファイル: helpers.py プロジェクト: migueloop/qautobots
def get_application_settings():
    """Reads environment variables to retrieve application settings.

    This method will return an object of application settings retrieved from
    environment variables. A default value will be used if one is not found.

    """
    config = get_config()
    protocol = config['application']['protocol']
    if 'port' in config['application']:
        host = '{url}:{port}'.format(**config['application'])
    else:
        host = config['application']['url']

    if 'env' in config['application']:
        # env = '?forceenv={env}'.format(**config['application'])
        env = ''
    else:
        env = ''

    return {'protocol': protocol, 'host': host, 'env': env}
コード例 #10
0
ファイル: helpers.py プロジェクト: chasepilon/qautobots
def get_application_settings():
    """Reads environment variables to retrieve application settings.

    This method will return an object of application settings retrieved from
    environment variables. A default value will be used if one is not found.

    """
    config = get_config()
    protocol = config['application']['protocol']
    if 'port' in config['application']:
        host = '{url}:{port}'.format(**config['application'])
    else:
        host = config['application']['url']

    if 'env' in config['application']:
        # env = '?forceenv={env}'.format(**config['application'])
        env = ''
    else:
        env = ''

    return {'protocol': protocol, 'host': host, 'env': env}
コード例 #11
0
ファイル: helpers.py プロジェクト: migueloop/qautobots
def get_dark_flag(flag):
    """Return Dark Flag for specified flag"""
    darkFlags = get_config()
    return darkFlags['darkflags'][flag]
コード例 #12
0
from __future__ import unicode_literals

import os
import sys

from qautobots.framework.qanfig import get_config


def main(argv, config):
    filename = argv
    decepticons = config

    if os.path.isfile(filename):
        os.remove(filename)

    with open(filename, 'w') as f:  # pragma: no cover
        for (dflag, value) in decepticons['decepticons'].items():
            if value:
                f.write('qautobots/tests/' + dflag + '\n')

if __name__ == '__main__':  # pragma: no cover
    main(sys.argv[1], get_config())
コード例 #13
0
ファイル: config.py プロジェクト: migueloop/qautobots
def get_current_browser():
    """Get the browser that is currently in use by GUI-Tests"""

    config = get_config()

    return config['selenium']['browser']
コード例 #14
0
ファイル: connection.py プロジェクト: chasepilon/qautobots
from __future__ import unicode_literals

from time import sleep
from urlparse import urljoin

from selenium.common.exceptions import WebDriverException

from qautobots.framework.helpers import get_application_settings
from qautobots.framework.qanfig import get_config

if get_config()['selenium']['remote']:
    from qautobots.framework.driver import CustomDriver
else:
    from selenium.webdriver import Firefox as CustomDriver


CONFIG = {
    'backend_data_indexing_time': 1.5,
    'page_load_time': 10,
    'sleep_interval': 1,
}


class Browser(CustomDriver):

    def _record_ajax_post(self):
        """Record every AJAX post and store in global JS varaible post_urls"""
        self.execute_script(
            """
            window.post_urls = window.post_urls || [];
            $.ajaxPrefilter(function(options) {
コード例 #15
0
from __future__ import unicode_literals

import os
import sys

from qautobots.framework.qanfig import get_config


def main(argv, config):
    filename = argv
    decepticons = config

    if os.path.isfile(filename):
        os.remove(filename)

    with open(filename, 'w') as f:  # pragma: no cover
        for (dflag, value) in decepticons['decepticons'].items():
            if value:
                f.write('qautobots/tests/' + dflag + '\n')


if __name__ == '__main__':  # pragma: no cover
    main(sys.argv[1], get_config())
コード例 #16
0
ファイル: helpers.py プロジェクト: chasepilon/qautobots
def get_dark_flag(flag):
    """Return Dark Flag for specified flag"""
    darkFlags = get_config()
    return darkFlags['darkflags'][flag]