Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'
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'
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'
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'
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'
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'
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'
def test_edit_view_command_detected():
assert iocommands.editor_command(r'\ev myview') == r'\ev'
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)
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