Merging upstream version 1.27.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d3f72a1e51
commit
cc1aa7d50e
15 changed files with 248 additions and 118 deletions
|
@ -254,23 +254,21 @@ def test_conditional_pager(monkeypatch):
|
|||
SPECIAL_COMMANDS['pager'].handler('')
|
||||
|
||||
|
||||
def test_reserved_space_is_integer():
|
||||
def test_reserved_space_is_integer(monkeypatch):
|
||||
"""Make sure that reserved space is returned as an integer."""
|
||||
def stub_terminal_size():
|
||||
return (5, 5)
|
||||
|
||||
old_func = shutil.get_terminal_size
|
||||
|
||||
shutil.get_terminal_size = stub_terminal_size
|
||||
mycli = MyCli()
|
||||
assert isinstance(mycli.get_reserved_space(), int)
|
||||
|
||||
shutil.get_terminal_size = old_func
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(shutil, 'get_terminal_size', stub_terminal_size)
|
||||
mycli = MyCli()
|
||||
assert isinstance(mycli.get_reserved_space(), int)
|
||||
|
||||
|
||||
def test_list_dsn():
|
||||
runner = CliRunner()
|
||||
with NamedTemporaryFile(mode="w") as myclirc:
|
||||
# keep Windows from locking the file with delete=False
|
||||
with NamedTemporaryFile(mode="w",delete=False) as myclirc:
|
||||
myclirc.write(dedent("""\
|
||||
[alias_dsn]
|
||||
test = mysql://test/test
|
||||
|
@ -281,6 +279,15 @@ def test_list_dsn():
|
|||
assert result.output == "test\n"
|
||||
result = runner.invoke(cli, args=args + ['--verbose'])
|
||||
assert result.output == "test : mysql://test/test\n"
|
||||
|
||||
# delete=False means we should try to clean up
|
||||
try:
|
||||
if os.path.exists(myclirc.name):
|
||||
os.remove(myclirc.name)
|
||||
except Exception as e:
|
||||
print(f"An error occurred while attempting to delete the file: {e}")
|
||||
|
||||
|
||||
|
||||
|
||||
def test_prettify_statement():
|
||||
|
@ -299,7 +306,8 @@ def test_unprettify_statement():
|
|||
|
||||
def test_list_ssh_config():
|
||||
runner = CliRunner()
|
||||
with NamedTemporaryFile(mode="w") as ssh_config:
|
||||
# keep Windows from locking the file with delete=False
|
||||
with NamedTemporaryFile(mode="w",delete=False) as ssh_config:
|
||||
ssh_config.write(dedent("""\
|
||||
Host test
|
||||
Hostname test.example.com
|
||||
|
@ -313,6 +321,13 @@ def test_list_ssh_config():
|
|||
assert "test\n" in result.output
|
||||
result = runner.invoke(cli, args=args + ['--verbose'])
|
||||
assert "test : test.example.com\n" in result.output
|
||||
|
||||
# delete=False means we should try to clean up
|
||||
try:
|
||||
if os.path.exists(ssh_config.name):
|
||||
os.remove(ssh_config.name)
|
||||
except Exception as e:
|
||||
print(f"An error occurred while attempting to delete the file: {e}")
|
||||
|
||||
|
||||
def test_dsn(monkeypatch):
|
||||
|
@ -466,7 +481,8 @@ def test_ssh_config(monkeypatch):
|
|||
runner = CliRunner()
|
||||
|
||||
# Setup temporary configuration
|
||||
with NamedTemporaryFile(mode="w") as ssh_config:
|
||||
# keep Windows from locking the file with delete=False
|
||||
with NamedTemporaryFile(mode="w",delete=False) as ssh_config:
|
||||
ssh_config.write(dedent("""\
|
||||
Host test
|
||||
Hostname test.example.com
|
||||
|
@ -489,8 +505,8 @@ def test_ssh_config(monkeypatch):
|
|||
MockMyCli.connect_args["ssh_user"] == "joe" and \
|
||||
MockMyCli.connect_args["ssh_host"] == "test.example.com" and \
|
||||
MockMyCli.connect_args["ssh_port"] == 22222 and \
|
||||
MockMyCli.connect_args["ssh_key_filename"] == os.getenv(
|
||||
"HOME") + "/.ssh/gateway"
|
||||
MockMyCli.connect_args["ssh_key_filename"] == os.path.expanduser(
|
||||
"~") + "/.ssh/gateway"
|
||||
|
||||
# When a user supplies a ssh config host as argument to mycli,
|
||||
# and used command line arguments, use the command line
|
||||
|
@ -512,6 +528,13 @@ def test_ssh_config(monkeypatch):
|
|||
MockMyCli.connect_args["ssh_host"] == "arg_host" and \
|
||||
MockMyCli.connect_args["ssh_port"] == 3 and \
|
||||
MockMyCli.connect_args["ssh_key_filename"] == "/path/to/key"
|
||||
|
||||
# delete=False means we should try to clean up
|
||||
try:
|
||||
if os.path.exists(ssh_config.name):
|
||||
os.remove(ssh_config.name)
|
||||
except Exception as e:
|
||||
print(f"An error occurred while attempting to delete the file: {e}")
|
||||
|
||||
|
||||
@dbtest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue