Adding upstream version 1.26.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
dcc1917157
commit
f7cfed155a
23 changed files with 328 additions and 52 deletions
|
@ -6,8 +6,8 @@ import mycli.sqlexecute
|
|||
|
||||
@pytest.fixture(scope="function")
|
||||
def connection():
|
||||
create_db('_test_db')
|
||||
connection = db_connection('_test_db')
|
||||
create_db('mycli_test_db')
|
||||
connection = db_connection('mycli_test_db')
|
||||
yield connection
|
||||
|
||||
connection.close()
|
||||
|
@ -22,7 +22,7 @@ def cursor(connection):
|
|||
@pytest.fixture
|
||||
def executor(connection):
|
||||
return mycli.sqlexecute.SQLExecute(
|
||||
database='_test_db', user=USER,
|
||||
database='mycli_test_db', user=USER,
|
||||
host=HOST, password=PASSWORD, port=PORT, socket=None, charset=CHARSET,
|
||||
local_infile=False, ssl=None, ssh_user=SSH_USER, ssh_host=SSH_HOST,
|
||||
ssh_port=SSH_PORT, ssh_password=None, ssh_key_filename=None
|
||||
|
|
|
@ -542,7 +542,14 @@ def test_favorite_name_suggestion(expression):
|
|||
suggestions = suggest_type(expression, expression)
|
||||
assert suggestions == [{'type': 'favoritequery'}]
|
||||
|
||||
|
||||
def test_order_by():
|
||||
text = 'select * from foo order by '
|
||||
suggestions = suggest_type(text, text)
|
||||
assert suggestions == [{'tables': [(None, 'foo', None)], 'type': 'column'}]
|
||||
|
||||
|
||||
def test_quoted_where():
|
||||
text = "'where i=';"
|
||||
suggestions = suggest_type(text, text)
|
||||
assert suggestions == [{'type': 'keyword'}]
|
||||
|
|
|
@ -25,7 +25,7 @@ os.environ['MYSQL_TEST_LOGIN_FILE'] = login_path_file
|
|||
CLI_ARGS = ['--user', USER, '--host', HOST, '--port', PORT,
|
||||
'--password', PASSWORD, '--myclirc', default_config_file,
|
||||
'--defaults-file', default_config_file,
|
||||
'_test_db']
|
||||
'mycli_test_db']
|
||||
|
||||
|
||||
@dbtest
|
||||
|
@ -283,6 +283,20 @@ def test_list_dsn():
|
|||
assert result.output == "test : mysql://test/test\n"
|
||||
|
||||
|
||||
def test_prettify_statement():
|
||||
statement = 'SELECT 1'
|
||||
m = MyCli()
|
||||
pretty_statement = m.handle_prettify_binding(statement)
|
||||
assert pretty_statement == 'SELECT\n 1;'
|
||||
|
||||
|
||||
def test_unprettify_statement():
|
||||
statement = 'SELECT\n 1'
|
||||
m = MyCli()
|
||||
unpretty_statement = m.handle_unprettify_binding(statement)
|
||||
assert unpretty_statement == 'SELECT 1;'
|
||||
|
||||
|
||||
def test_list_ssh_config():
|
||||
runner = CliRunner()
|
||||
with NamedTemporaryFile(mode="w") as ssh_config:
|
||||
|
@ -305,19 +319,25 @@ def test_dsn(monkeypatch):
|
|||
# Setup classes to mock mycli.main.MyCli
|
||||
class Formatter:
|
||||
format_name = None
|
||||
|
||||
class Logger:
|
||||
def debug(self, *args, **args_dict):
|
||||
pass
|
||||
|
||||
def warning(self, *args, **args_dict):
|
||||
pass
|
||||
|
||||
class MockMyCli:
|
||||
config = {'alias_dsn': {}}
|
||||
|
||||
def __init__(self, **args):
|
||||
self.logger = Logger()
|
||||
self.destructive_warning = False
|
||||
self.formatter = Formatter()
|
||||
|
||||
def connect(self, **args):
|
||||
MockMyCli.connect_args = args
|
||||
|
||||
def run_query(self, query, new_line=True):
|
||||
pass
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ def test_table_and_columns_query(executor):
|
|||
@dbtest
|
||||
def test_database_list(executor):
|
||||
databases = executor.databases()
|
||||
assert '_test_db' in databases
|
||||
assert 'mycli_test_db' in databases
|
||||
|
||||
|
||||
@dbtest
|
||||
|
@ -276,6 +276,7 @@ def test_multiple_results(executor):
|
|||
@pytest.mark.parametrize(
|
||||
'version_string, species, parsed_version_string, version',
|
||||
(
|
||||
('5.7.25-TiDB-v6.1.0','TiDB', '5.7.25', 50725),
|
||||
('5.7.32-35', 'Percona', '5.7.32', 50732),
|
||||
('5.7.32-0ubuntu0.18.04.1', 'MySQL', '5.7.32', 50732),
|
||||
('10.5.8-MariaDB-1:10.5.8+maria~focal', 'MariaDB', '10.5.8', 100508),
|
||||
|
|
|
@ -41,8 +41,8 @@ dbtest = pytest.mark.skipif(
|
|||
def create_db(dbname):
|
||||
with db_connection().cursor() as cur:
|
||||
try:
|
||||
cur.execute('''DROP DATABASE IF EXISTS _test_db''')
|
||||
cur.execute('''CREATE DATABASE _test_db''')
|
||||
cur.execute('''DROP DATABASE IF EXISTS mycli_test_db''')
|
||||
cur.execute('''CREATE DATABASE mycli_test_db''')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue