Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy committed Nov 20, 2012
1 parent 420af62 commit 32f2b29
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion master/buildbot/config.py
Expand Up @@ -552,7 +552,7 @@ def load_www(self, filename, config_dict, errors):
public_html = self.www["public_html"] = os.path.join(os.path.dirname(filename),
"public_html")
if not os.path.isdir(public_html):
msg = "www['public_html'] must be an existing, writable " \
msg = "www['public_html'] must be an existing " \
"directory; got '%s'" % (public_html,)
errors.addError(msg)

Expand Down
7 changes: 3 additions & 4 deletions master/buildbot/scripts/update_js.py
Expand Up @@ -147,10 +147,7 @@ def minifyJS(config, www, workdir):
# Perhaps its even only needed for large scale buildbot where we can require installation of
# node and java in the master, and where people dont care about sdists.
if skip_minify:
dest = os.path.join(workdir, "js.built")
if not os.path.isdir(dest):
print "js.built does not exist; cannot proceed"
return False
# link js to js.built, so that the non minified code is used
os.symlink("js", os.path.join(workdir, "js.built"))
return True

Expand All @@ -176,6 +173,8 @@ def minifyJS(config, www, workdir):
return True

def updateJS(config, master_cfg=None):
if 'skip_updatejs' in config:
return 0
if not master_cfg:
from upgrade_master import loadConfig # avoid recursive import
master_cfg = loadConfig(config)
Expand Down
12 changes: 7 additions & 5 deletions master/buildbot/test/unit/test_config.py
Expand Up @@ -715,16 +715,18 @@ def test_load_www_default(self):
public_html=None))

def test_load_www_port(self):
pwd = os.getcwd()
self.cfg.load_www(self.filename,
dict(www=dict(port=9888)), self.errors)
dict(www=dict(port=9888, public_html=pwd)), self.errors)
self.assertResults(www=dict(port=9888, url='http://localhost:9888/',
public_html=None))
public_html=pwd))

def test_load_www_url_no_slash(self):
pwd = os.getcwd()
self.cfg.load_www(self.filename,
dict(www=dict(url='http://foo', port=20)), self.errors)
dict(www=dict(url='http://foo', port=20, public_html=pwd)), self.errors)
self.assertResults(www=dict(port=20, url='http://foo/',
public_html=None))
public_html=pwd))

def test_load_www_public_html(self):
pwd = os.getcwd()
Expand All @@ -737,7 +739,7 @@ def test_load_www_public_html_does_not_exist(self):
self.cfg.load_www(self.filename,
dict(www=dict(public_html=r'/does/not\exist/no')),
self.errors)
self.assertConfigError(self.errors, 'public_html directory')
self.assertConfigError(self.errors, 'must be an existing directory')


class MasterConfig_checkers(ConfigErrorsMixin, unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/test/unit/test_scripts_create_master.py
Expand Up @@ -25,6 +25,7 @@

def mkconfig(**kwargs):
config = dict(force=False, relocatable=False, config='master.cfg',
skip_updatejs = True,
db='sqlite:///state.sqlite', basedir=os.path.abspath('basedir'),
quiet=False, **{'no-logrotate':False, 'log-size':'10000000',
'log-count':'10'})
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_scripts_upgrade_master.py
Expand Up @@ -25,7 +25,7 @@
from buildbot.test.util import dirs, misc, compat

def mkconfig(**kwargs):
config = dict(quiet=False, replace=False, basedir='test')
config = dict(quiet=False, replace=False, basedir='test', skip_updatejs=True)
config.update(kwargs)
return config

Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/test/unit/test_www_service.py
Expand Up @@ -14,6 +14,7 @@
# Copyright Buildbot Team Members

import mock
import os
from buildbot.www import service, ui, rest
from twisted.trial import unittest
from twisted.web import static
Expand All @@ -27,7 +28,8 @@ def setUp(self):
self.svc = service.WWWService(self.master)

def makeConfig(self, **kwargs):
w = dict(url='h:/', port=None)
pwd = os.getcwd()
w = dict(url='h:/', port=None, public_html=pwd)
w.update(kwargs)
new_config = mock.Mock()
new_config.www = w
Expand Down Expand Up @@ -92,8 +94,6 @@ def test_setup_site(self):
ui.UIResource)
self.assertIsInstance(root.getChildWithDefault('api', req),
rest.RestRootResource)
self.assertIsInstance(root.getChildWithDefault('static', req),
static.File)

# ..and that the / URI redirects properly
req = self.make_request([''])
Expand Down

0 comments on commit 32f2b29

Please sign in to comment.