def main(): parser = create_parser() parsed_args = parser.parse_args() if parsed_args.version: parser.exit("paragres %s" % pkg_resources.require("paragres")[0].version) error_message = verify_args(parsed_args) if error_message: error(parser, error_message) command = Command(parsed_args) command.run() return 0
def test_run_destination_heroku(self, mock_check_call, mock_check_output): mock_check_output.return_value = b' http://example.com/ ' command = Command(self.parser.parse_args(['-c', '-s', 'app1', '-d', 'app2'])) command.databases['source']['name'] = 'srcdb' command.run() expected_calls = [call(['heroku', 'pg:backups:capture', '--app=app1']), call(['heroku', 'pg:reset', '--app=app2', 'DATABASE_URL']), call(['heroku', 'pg:backups:restore', 'http://example.com/', '--app=app2', 'DATABASE', '--confirm', 'app2'])] self.assertEqual(expected_calls, mock_check_call.call_args_list) mock_check_output.assert_called_once_with(['heroku', 'pg:backups:url', '--app=app1'])
def test_run_destination_postgres(self, mock_check_call): working_dir = os.path.realpath(os.path.dirname(__file__)) settings_file = os.path.join(working_dir, 'data', 'settings.py') command = Command(self.parser.parse_args(['-t', settings_file, '-o', settings_file, '-b', 'sourcedb'])) command.run() expected_calls = [ call(['pg_dump', '-Fc', '--no-acl', '--no-owner', '--dbname=sourcedb', StringStartsWith('--file=sourcedb-backup-'), '--user=username', '--host=host', '--port=port']), call(['dropdb', '--if-exists', 'dbname', '--user=username', '--host=host', '--port=port']), call(['createdb', 'dbname', '--user=username', '--host=host', '--port=port', '--owner=username']), call(['pg_restore', '--no-acl', '--no-owner', '--dbname=dbname', StringStartsWith('sourcedb-backup-'), '--user=username', '--host=host', '--port=port'])] self.assertEqual(expected_calls, mock_check_call.call_args_list)
def test_run_nothing_to_do(self, mock_check_call): command = Command(self.parser.parse_args([])) command.run() self.assertEqual([], mock_check_call.call_args_list)