def pushCouchApp(sourceDir, destURL): try: conf = cfg.Config() cmd.push(conf, sourceDir, destURL) log.warning("Deployed CouchApp from '{0}' to '{1}'".format(sourceDir, destURL)) except: print repr(sys.exc_info()) log.warning("Unable to push CouchApp at '{0}'".format(sourceDir))
def _pushCouchApp(sourceDir, destURL): try: conf = cfg.Config() cmd.push(conf, sourceDir, destURL) print("Deployed CouchApp from '{0}' to '{1}'".format(sourceDir, destURL)) except: print repr(sys.exc_info()) print("Unable to push CouchApp at '{0}'".format(sourceDir))
def test_push_export_outside(mock_doc): ''' $ couchapp push --export /path/to/app ''' conf = NonCallableMock(name='conf') appdir = '/mock_dir' ret_code = commands.push(conf, None, appdir, export=True) mock_doc.assert_called_once_with(appdir, create=False, docid=None) assert ret_code == 0
def test_push_export_to_file(mock_doc, mock_util): ''' $ couchapp push --export --output /path/to/json /appdir ''' conf = NonCallableMock(name='conf') appdir = '/mock_dir' output_file = '/file' ret_code = commands.push(conf, appdir, export=True, output=output_file) mock_doc.assert_called_once_with(appdir, create=False, docid=None) mock_util.write_json.assert_called_once_with( output_file, '{"status": "ok"}' ) assert ret_code == 0
def test_push_with_pushdocs(mock_doc, mock_hook, mock_pushdocs, mock_exists): ''' if appdir/_docs exists, push will invoke pushdocs ''' conf = NonCallableMock(name='conf') appdir = '/mock_dir' dest = 'http://localhost' docspath = os.path.join(appdir, '_docs') def check_docspath(docspath_): return docspath_ == docspath mock_exists.side_effect = check_docspath ret_code = commands.push(conf, appdir, dest) mock_pushdocs.assert_called_once_with(conf, docspath, dest, dest) assert ret_code == 0
def test_push_outside(mock_doc, mock_hook): ''' $ couchapp push /path/to/app dest ''' conf = NonCallableMock(name='conf') path = None appdir = '/mock_dir' dest = 'http://localhost' hook_expect = [ ((conf, appdir, 'pre-push'), {'dbs': dest}), ((conf, appdir, 'post-push'), {'dbs': dest}), ] conf.get_dbs.return_value = dest ret_code = commands.push(conf, path, appdir, dest) mock_doc.assert_called_once_with(appdir, create=False, docid=None) mock_doc().push.assert_called_once_with(dest, False, False, False) assert mock_hook.call_args_list == hook_expect assert ret_code == 0
if port: host = "%s:%s" % (host, port) server_url = "%s://%s" % (scheme, host) server = couchdb.Server(server_url) if user and pwd: server.resource.credentials = (user, pwd) try: print >> sys.stderr, "server connection test...", print >> sys.stderr, "found version %s" % (server.version(), ) except socket.error: print >> sys.stderr, "" raise RuntimeError("could not connect to %s" % (server_url, )) try: db = server[dbname] except couchdb.http.ResourceNotFound: raise RuntimeError("no db %s on %s" % (dbname, server_url)) (design_path, design_name) = design_dir.rsplit('/', 1) os.chdir(design_path) print >> sys.stderr, "Pushing {} to {}".format(design_name, host), commands.push(Config(), design_name, real_url) sys.exit(0)
def test_push_app_path_error(): conf = NonCallableMock(name='conf') dest = 'http://localhost' commands.push(conf, None, dest)