def test_rcpath_empty_env(user_rcpath): ''' Empty ``COUCHAPPCONF_PATH`` ''' import couchapp.util as util util._rcpath = None assert rcpath() == ['/mock/couchapp.conf'], rcpath() assert user_rcpath.called
def test_rcpath_env(user_rcpath, isdir, listdir): ''' With ``COUCHAPPCONF_PATH`` set ''' import couchapp.util as util util._rcpath = None def _isdir(path): return True if path == '/mock' else False def _listdir(path): return ['foo', 'bar', 'couchapp.conf'] if path == '/mock' else [] isdir.side_effect = _isdir listdir.side_effect = _listdir assert rcpath() == ['/mock/couchapp.conf', '/tmp/fake.conf'], rcpath() assert not user_rcpath.called
def __init__(self): self.rc_path = util.rcpath() self.global_conf = self.load(self.rc_path, self.DEFAULTS) self.local_conf = {} self.app_dir = util.findcouchapp(os.getcwd()) if self.app_dir: self.local_conf = self.load_local(self.app_dir) self.conf = self.global_conf.copy() self.conf.update(self.local_conf)
def test_rcpath_cached(_rcpath, user_rcpath): ''' Global ``_rcpath`` is not None already ''' assert _rcpath == rcpath() assert not user_rcpath.called