本文整理汇总了Python中indico.tests.config.TestConfig.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python TestConfig.getInstance方法的具体用法?Python TestConfig.getInstance怎么用?Python TestConfig.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.tests.config.TestConfig
的用法示例。
在下文中一共展示了TestConfig.getInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _runSeleniumCycle
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _runSeleniumCycle(self):
"""
Run selenium over the existing test suite (or a specific test)
"""
test_config = TestConfig.getInstance()
mode = self.options.valueOf('mode', test_config.getRunMode())
browser = self.options.valueOf('browser')
if browser:
browsers = [browser]
elif mode == 'local':
browsers = [test_config.getStandaloneBrowser()]
else:
browsers = test_config.getGridBrowsers()
args = self._buildArgs()
# Execute the tests
result = True
os.environ['INDICO_TEST_MODE'] = mode or ''
os.environ['INDICO_TEST_URL'] = self.options.valueOf('server_url') or ''
for browser in browsers:
os.environ['INDICO_TEST_BROWSER'] = browser
testResult = nose.run(argv=args)
result = result and testResult
self._info("%s: %s\n" % \
(browser, testResult and 'OK' or 'Error'))
return result
示例2: setUpModule
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def setUpModule():
global webd
config = TestConfig.getInstance()
browser = os.environ['INDICO_TEST_BROWSER']
mode = os.environ['INDICO_TEST_MODE']
server_url = os.environ.get('INDICO_TEST_URL')
if mode == 'remote':
capabilities = {
'firefox': DesiredCapabilities.FIREFOX,
'chrome': DesiredCapabilities.FIREFOX,
'ie': DesiredCapabilities.INTERNETEXPLORER,
'ipad': DesiredCapabilities.IPAD,
'iphone': DesiredCapabilities.IPHONE,
'android': DesiredCapabilities.ANDROID,
'htmlunit': DesiredCapabilities.HTMLUNITWITHJS
}
cap = capabilities[browser]
webd = webdriver.Remote(server_url, desired_capabilities=cap)
else:
drivers = {
'firefox': webdriver.Firefox,
'chrome': webdriver.Chrome,
'ie': webdriver.Ie
}
webd = drivers[browser]();
webd.implicitly_wait(15)
示例3: _setFakeConfig
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _setFakeConfig(self, custom):
"""
Sets a fake configuration for the current process, using a temporary directory
"""
config = Config.getInstance()
test_config = TestConfig.getInstance()
temp = tempfile.mkdtemp(prefix="indico_")
self._info('Using %s as temporary dir' % temp)
os.mkdir(os.path.join(temp, 'log'))
os.mkdir(os.path.join(temp, 'archive'))
indicoDist = pkg_resources.get_distribution('indico')
htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs')
etcDir = indicoDist.get_resource_filename('indico', 'etc')
# minimal defaults
defaults = {
'BaseURL': 'http://localhost:8000/indico',
'BaseSecureURL': '',
'UseXSendFile': False,
'AuthenticatorList': ['Local'],
'SmtpServer': ('localhost', 58025),
'SmtpUseTLS': 'no',
'DBConnectionParams': ('localhost', TestConfig.getInstance().getFakeDBPort()),
'LogDir': os.path.join(temp, 'log'),
'XMLCacheDir': os.path.join(temp, 'cache'),
'HtdocsDir': htdocsDir,
'ArchiveDir': os.path.join(temp, 'archive'),
'UploadedFilesTempDir': os.path.join(temp, 'tmp'),
'ConfigurationDir': etcDir
}
defaults.update(custom)
# set defaults
config.reset(defaults)
Config.setInstance(config)
self._cfg = config
# re-configure logging and template generator, so that paths are updated
from MaKaC.common import TemplateExec
from MaKaC.common.logger import Logger
TemplateExec.mako = TemplateExec._define_lookup()
Logger.reset()
示例4: _runFakeWebServer
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _runFakeWebServer(self):
"""
Spawn a new refserver-based thread using the test db
"""
config = TestConfig.getInstance()
refserver = RefServer(config.getWebServerHost(), int(config.getWebServerPort()))
t = threading.Thread(target=refserver.run)
t.setDaemon(True)
t.start()
return refserver.addr
示例5: _setFakeConfig
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _setFakeConfig(self, custom):
"""
Sets a fake configuration for the current process, using a temporary directory
"""
config = Config.getInstance()
temp = tempfile.mkdtemp(prefix="indico_")
self._info('Using %s as temporary dir' % temp)
os.mkdir(os.path.join(temp, 'log'))
os.mkdir(os.path.join(temp, 'archive'))
indicoDist = pkg_resources.get_distribution('indico')
htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs')
etcDir = indicoDist.get_resource_filename('indico', 'etc')
# minimal defaults
defaults = {
'Debug': True,
'BaseURL': 'http://localhost:8000',
'BaseSecureURL': '',
'AuthenticatorList': [('Local', {})],
'SmtpServer': ('localhost', 58025),
'SmtpUseTLS': 'no',
'DBConnectionParams': ('127.0.0.1', TestConfig.getInstance().getFakeDBPort()),
'LogDir': os.path.join(temp, 'log'),
'XMLCacheDir': os.path.join(temp, 'cache'),
'HtdocsDir': htdocsDir,
'ArchiveDir': os.path.join(temp, 'archive'),
'UploadedFilesTempDir': os.path.join(temp, 'tmp'),
'ConfigurationDir': etcDir
}
defaults.update(custom)
# set defaults
config.reset(defaults)
Config.setInstance(config)
self._cfg = config
# Update assets environment
core_env.directory = core_env.directory.replace('/opt/indico/htdocs', config.getHtdocsDir())
core_env.load_path = [path.replace('/opt/indico/htdocs', config.getHtdocsDir()) for path in core_env.load_path]
core_env.url_mapping = {path.replace('/opt/indico/htdocs', config.getHtdocsDir()): url for path, url in
core_env.url_mapping.iteritems()}
core_env.config['PYSCSS_LOAD_PATHS'] = [x.replace('/opt/indico/htdocs', config.getHtdocsDir()) for x in
core_env.config['PYSCSS_LOAD_PATHS']]
# re-configure logging and template generator, so that paths are updated
from MaKaC.common import TemplateExec
from MaKaC.common.logger import Logger
TemplateExec.mako = TemplateExec._define_lookup()
Logger.reset()
示例6: _runFakeWebServer
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _runFakeWebServer(self):
"""
Spawn a new refserver-based thread using the test db
"""
config = TestConfig.getInstance()
server = WerkzeugServer(config.getWebServerHost(), int(config.getWebServerPort()), use_debugger=False)
server.make_server()
t = threading.Thread(target=server.run)
t.setDaemon(True)
t.start()
return server.addr
示例7: setup
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def setup(cls):
# lazy import because we don't want it to be imported by default
# (as the plugin system currently loads all submodules)
from indico.tests.config import TestConfig
PluginsHolder().loadAllPlugins()
testConfig = TestConfig.getInstance()
vidyoOptions = CollaborationTools.getPlugin("Vidyo").getOptions()
vidyoOptions["indicoUsername"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoUsername"])
vidyoOptions["indicoPassword"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoPassword"])
cls._setupDone = True
示例8: __init__
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def __init__(self, **kwargs):
"""
Options can be passed as kwargs, currently the following is supported:
"""
self.err = None
self.out = None
# make a TestConfig instance available everywhere
self.config = TestConfig.getInstance()
# initialize allowed options
self.options = OptionProxy(self._runnerOptions)
self.options.configure(**kwargs)
self._logger = logging.getLogger('test')
示例9: _startManageDB
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _startManageDB(self):
port = TestConfig.getInstance().getFakeDBPort()
self._info("Starting fake DB in port %s" % port)
self._startFakeDB('localhost', port)
示例10: buildConfFile
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def buildConfFile(self, confFilePath, coverage):
"""
Builds a driver config file
"""
confTemplateDir = os.path.join(self.setupDir,
'javascript',
'unit')
confTemplatePath = os.path.join(confTemplateDir, 'confTemplate.conf')
absoluteTestsDir = os.path.join(self.setupDir,
"javascript",
"unit",
"tests")
absolutePluginDir = os.path.join(self.setupDir,
"..",
"..",
"indico",
"MaKaC",
"plugins")
try:
#lines needed to activate coverage plugin
coverageConf = """\nplugin:
- name: \"coverage\"
jar: \"plugins/%s\"
module: \"com.google.jstestdriver.coverage.CoverageModule\"""" % \
TestConfig.getInstance().getJSCoverageFilename()
except KeyError:
return "Please, specify a JSCoverageFilename in tests.conf\n"
try:
#retrieve and store the template file
f = open(confTemplatePath)
confTemplate = f.read()
f.close()
#adding tests files from tests folder
for root, __, files in os.walk(absoluteTestsDir):
for name in files:
if name.endswith(".js"):
absoluteFilePath = os.path.join(root, name)
relativeFilePath = relpathto(confTemplateDir,
absoluteFilePath)
confTemplate += "\n - %s" % os.path.join(relativeFilePath)
#adding plugins test files
for root, __, files in os.walk(absolutePluginDir):
for name in files:
if name.endswith(".js") and \
root.find("/tests/javascript/unit") > 0:
absoluteFilePath = os.path.join(root, name)
relativeFilePath = relpathto(confTemplateDir,
absoluteFilePath)
confTemplate += "\n - %s" % os.path.join('..',
'..',
relativeFilePath)
#addind coverage if necessary
if coverage:
confTemplate += coverageConf
#writing the complete configuration in a file
confFile = open(os.path.join(self.setupDir, 'javascript', 'unit',
confFilePath), 'w')
confFile.write(confTemplate)
confFile.close()
return ""
except IOError, e:
return "JS Unit Tests - Could not open a file. (%s)" % e
示例11: _run
# 需要导入模块: from indico.tests.config import TestConfig [as 别名]
# 或者: from indico.tests.config.TestConfig import getInstance [as 别名]
def _run(self):
#conf file used at run time
try:
#Starting js-test-driver server
server = subprocess.Popen(["java", "-jar",
os.path.join(self.setupDir,
'javascript',
'unit',
TestConfig.getInstance().
getJSUnitFilename()),
"--port",
"9876",
"--browser",
"firefox"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
time.sleep(2)
#constructing conf file depending on installed plugins and
#coverage activation
success = self.buildConfFile(JSTEST_CFG_FILE, self.coverage)
if success != "":
self._error(success)
return False
#switching directory to run the tests
os.chdir(os.path.join(self.setupDir, 'javascript', 'unit'))
#check if server is ready
for i in range(5):
jsDryRun = commands.getstatusoutput(("java -jar "
"%s"
" --config "
"%s"
" --tests Fake.dryRun") %\
(TestConfig.getInstance().
getJSUnitFilename(),
JSTEST_CFG_FILE))
# Not very nice error checking, but how to do it nicely?
if "browsers" in jsDryRun[1] or \
"Connection refused" in jsDryRun[1]:
print "Js-test-driver server has not started yet. " \
"Attempt #%s\n" % (i+1)
time.sleep(5)
else:
#server is ready
break
else:
raise Exception('Could not start js unit tests because '
'js-test-driver server cannot be started.\n')
#setting tests to run
toTest = ""
if self.specify:
toTest = self.specify
else:
toTest = "all"
command = ("java -jar %s "
"--config %s "
"--verbose "
"--tests %s ") % \
(TestConfig.getInstance().getJSUnitFilename(),
JSTEST_CFG_FILE,
toTest)
if self.coverage:
# path relative to the jar file
command += "--testOutput %s" % \
os.path.join('..', '..', 'report', 'jscoverage')
#running tests
jsTest = commands.getoutput(command)
#delete built conf file
os.unlink(JSTEST_CFG_FILE)
#restoring directory
os.chdir(self.setupDir)
except OSError, e:
self._error("[ERR] Could not start js-test-driver server - command "
"\"java\" needs to be in your PATH. (%s)\n" % e)