Ejemplo n.º 1
0
def stub_config():
    """Builds a standardized Configuration object and returns it, but does
    not load it as the active configuration returned by
    dallinger.config.get_config()
    """
    defaults = {
        u'ad_group': u'Test ad group',
        u'approve_requirement': 95,
        u'assign_qualifications': True,
        u'auto_recruit': True,
        u'aws_access_key_id': u'fake aws key',
        u'aws_secret_access_key': u'fake aws secret',
        u'aws_region': u'us-east-1',
        u'base_payment': 0.01,
        u'base_port': 5000,
        u'browser_exclude_rule': u'MSIE, mobile, tablet',
        u'clock_on': True,
        u'contact_email_on_error': u'*****@*****.**',
        u'dallinger_email_address': u'*****@*****.**',
        u'database_size': u'standard-0',
        u'redis_size': u'premium-0',
        u'database_url': u'postgresql://postgres@localhost/dallinger',
        u'description': u'fake HIT description',
        u'duration': 1.0,
        u'dyno_type': u'free',
        u'heroku_auth_token': u'heroku secret',
        u'heroku_team': u'',
        u'host': u'0.0.0.0',
        u'id': u'some experiment uid',
        u'keywords': u'kw1, kw2, kw3',
        u'lifetime': 1,
        u'logfile': u'-',
        u'loglevel': 0,
        u'mode': u'debug',
        u'notification_url': u'https://url-of-notification-route',
        u'num_dynos_web': 1,
        u'num_dynos_worker': 1,
        u'organization_name': u'Monsters University',
        u'sentry': True,
        u'smtp_host': u'smtp.fakehost.com:587',
        u'smtp_username': u'fake email username',
        u'smtp_password': u'fake email password',
        u'threads': u'1',
        u'title': u'fake experiment title',
        u'us_only': True,
        u'webdriver_type': u'phantomjs',
        u'whimsical': True
    }
    from dallinger.config import default_keys
    from dallinger.config import Configuration
    config = Configuration()
    for key in default_keys:
        config.register(*key)
    config.extend(defaults.copy())
    config.ready = True

    return config
Ejemplo n.º 2
0
def stub_config():
    """Builds a standardized Configuration object and returns it, but does
    not load it as the active configuration returned by
    dallinger.config.get_config()
    """
    defaults = {
        u"ad_group": u"Test ad group",
        u"approve_requirement": 95,
        u"assign_qualifications": True,
        u"auto_recruit": True,
        u"aws_access_key_id": u"fake aws key",
        u"aws_secret_access_key": u"fake aws secret",
        u"aws_region": u"us-east-1",
        u"base_payment": 0.01,
        u"base_port": 5000,
        u"browser_exclude_rule": u"MSIE, mobile, tablet",
        u"clock_on": False,
        u"contact_email_on_error": u"*****@*****.**",
        u"dallinger_email_address": u"*****@*****.**",
        u"database_size": u"standard-0",
        u"redis_size": u"premium-0",
        u"database_url": u"postgresql://postgres@localhost/dallinger",
        u"description": u"fake HIT description",
        u"duration": 1.0,
        u"dyno_type": u"free",
        u"heroku_auth_token": u"heroku secret",
        u"heroku_team": u"",
        u"host": u"0.0.0.0",
        u"id": u"some experiment uid",
        u"keywords": u"kw1, kw2, kw3",
        u"lifetime": 1,
        u"logfile": u"-",
        u"loglevel": 0,
        u"mode": u"debug",
        u"num_dynos_web": 1,
        u"num_dynos_worker": 1,
        u"organization_name": u"Monsters University",
        u"sentry": True,
        u"smtp_host": u"smtp.fakehost.com:587",
        u"smtp_username": u"fake email username",
        u"smtp_password": u"fake email password",
        u"threads": u"1",
        u"title": u"fake experiment title",
        u"us_only": True,
        u"webdriver_type": u"phantomjs",
        u"whimsical": True,
        u"replay": False,
        u"worker_multiplier": 1.5,
    }
    from dallinger.config import default_keys
    from dallinger.config import Configuration

    config = Configuration()
    for key in default_keys:
        config.register(*key)
    config.extend(defaults.copy())
    # Patch load() so we don't update any key/value pairs from actual files:
    config.load = mock.Mock(side_effect=lambda: setattr(config, "ready", True))
    config.ready = True

    return config