How to use pgspecial - 10 common examples

To help you get started, we’ve selected a few pgspecial examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_plain_editor_commands_detected():
    assert not iocommands.editor_command('select * from foo')
    assert not iocommands.editor_command(r'\easy does it')

    assert iocommands.editor_command(r'\e') == r'\e'
    assert iocommands.editor_command(r'\e myfile.txt') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e') == r'\e'

    assert iocommands.editor_command(r'  \e  ') == r'\e'
    assert iocommands.editor_command(r'select * from foo \e  ') == r'\e'
github dbcli / pgspecial / tests / test_internal.py View on Github external
def test_edit_view_command_detected():
    assert iocommands.editor_command(r'\ev myview') == r'\ev'
github dbcli / pgcli / tests / test_pgexecute.py View on Github external
def test_exit_without_active_connection(executor):
    quit_handler = MagicMock()
    pgspecial = PGSpecial()
    pgspecial.register(
        quit_handler,
        "\\q",
        "\\q",
        "Quit pgcli.",
        arg_type=NO_QUERY,
        case_sensitive=True,
        aliases=(":q",),
    )

    with patch.object(executor, "conn", BrokenConnection()):
        # we should be able to quit the app, even without active connection
        run(executor, "\\q", pgspecial=pgspecial)
        quit_handler.assert_called_once()

        # an exception should be raised when running a query without active connection
        with pytest.raises(psycopg2.InterfaceError):
            run(executor, "select 1", pgspecial=pgspecial)
github dbcli / pgcli / tests / test_pgexecute.py View on Github external
def test_exit_without_active_connection(executor):
    quit_handler = MagicMock()
    pgspecial = PGSpecial()
    pgspecial.register(
        quit_handler,
        "\\q",
        "\\q",
        "Quit pgcli.",
        arg_type=NO_QUERY,
        case_sensitive=True,
        aliases=(":q",),
    )

    with patch.object(executor, "conn", BrokenConnection()):
        # we should be able to quit the app, even without active connection
        run(executor, "\\q", pgspecial=pgspecial)
        quit_handler.assert_called_once()

        # an exception should be raised when running a query without active connection