def test_create(self): """Tests the navigator.create function""" con = DbTestCase.connection options = Config.init(['dbnav-c.sqlite/user'], navigator.args.parser) options.show = 'connections' self.assertEqual( [None], navigator.create(None, options)) options.show = 'databases' self.assertEqual( ['dbnav-c.sqlite//'], map(str, navigator.create(con, options))) options.database = 'db' self.assertEqual( [], map(str, navigator.create(con, options))) options = Config.init(['dbnav-c.sqlite/user?'], navigator.args.parser) self.assertEqual( ['dbnav-c.sqlite/'], map(str, navigator.create(con, options)))
def init(argv, parser): left = Config.init(argv, parser) left.uri = left.left left.update_parsers() right = Config.init(argv, parser) right.uri = right.right right.update_parsers() return (left, right)
def test_options(self): """Tests options""" config = Config.init( ['-r', '--database', 'dbnav.sqlite/article'], grapher.args.parser) config.database = 'db' self.assertEqual( 12, len(grapher.DatabaseGrapher(config).run()))
def test_create_values(self): """Tests the create_values function""" con = DbTestCase.connection user = con.table('user') options = Config.init(['dbnav-c.sqlite/user?'], navigator.args.parser) options.simplify = False self.assertIsNotNone( navigator.create_values(con, user, options) )
def main(args=None): if args is None: args = sys.argv[1:] config = Config.init(args, parser) { 'start': start, 'stop': stop, 'restart': restart, 'status': status }.get(config.command)(config)
def test_filter(self): """Tests the filter function""" self.assertEqual( True, dbc.PostgreSQLConnection( 'uri', 'host', '3333', 'db', 'user', 'password' ).filter_(Config.init(['user@host/db/'], navigator.args.parser))) self.assertEqual( False, dbc.PostgreSQLConnection( 'postgresql://{user}:{password}@{host}/{database}', 'host', '3333', 'db', 'user', 'password' ).filter_({'postgresql': Opts(user='******', host=None)}))
def main(args=None): if args is None: args = sys.argv[1:] return DatabaseStatus(Config.init(args, parser)).write()
def run(args): return DatabaseStatus(Config.init(args, parser)).run()
def execute(args): """ Directly calls the execute method and avoids using the wrapper """ return DatabaseStatus(Config.init(args, parser)).execute()
def run(args): return DatabaseExporter(Config.init(args, parser)).run()
def run(args): return DatabaseGrapher(Config.init(args, parser)).run()
# You should have received a copy of the GNU General Public License # along with Database Navigator. If not, see <http://www.gnu.org/licenses/>. # import json import dbnav import urllib2 import sys from dbnav.config import Config from dbnav.exporter import parser from dbnav.exporter.writer import SqlInsertWriter try: response = urllib2.urlopen( 'http://localhost:8020/exporter', json.dumps(sys.argv[1:])) o = dbnav.json.from_json(json.load(response)) print SqlInsertWriter(Config.init(sys.argv[:1], parser)).write(o) except urllib2.HTTPError as e: print dbnav.json.from_json(json.load(e)) except urllib2.URLError as e: print 'Daemon not available', e except BaseException as e: print e.__class__, e import pdb _type, value, tb = sys.exc_info() # pragma: no cover # traceback.print_exc() pdb.post_mortem(tb) # pragma: no cover
# # You should have received a copy of the GNU General Public License # along with Database Navigator. If not, see <http://www.gnu.org/licenses/>. # import json import dbnav import urllib2 import sys from dbnav.config import Config from dbnav.exporter import parser from dbnav.exporter.writer import SqlInsertWriter try: response = urllib2.urlopen('http://localhost:8020/exporter', json.dumps(sys.argv[1:])) o = dbnav.json.from_json(json.load(response)) print SqlInsertWriter(Config.init(sys.argv[:1], parser)).write(o) except urllib2.HTTPError as e: print dbnav.json.from_json(json.load(e)) except urllib2.URLError as e: print 'Daemon not available', e except BaseException as e: print e.__class__, e import pdb _type, value, tb = sys.exc_info() # pragma: no cover # traceback.print_exc() pdb.post_mortem(tb) # pragma: no cover
def test_trace(self): """Tests the trace option""" self.assertEqual( True, Config.init(['--trace'], navigator.args.parser).trace)
def run(args): return DatabaseNavigator(Config.init(args, parser)).run()