Merging upstream version 1.10.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4551c2c19a
commit
7e40561ca0
23 changed files with 298 additions and 99 deletions
|
@ -135,3 +135,10 @@ Token.Toolbar.Arg.Text = nobold
|
|||
[favorite_queries]
|
||||
q_param = select * from test where name=?
|
||||
sh_param = select * from test where id=$1
|
||||
|
||||
# Startup commands
|
||||
# litecli commands or sqlite commands to be executed on startup.
|
||||
# some of them will require you to have a database attached.
|
||||
# they will be executed in the same order as they appear in the list.
|
||||
[startup_commands]
|
||||
commands = "create table startupcommands(a text)", "insert into startupcommands values('abc')"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from litecli.packages.completion_engine import suggest_type
|
||||
from test_completion_engine import sorted_dicts
|
||||
from litecli.packages.special.utils import format_uptime
|
||||
from litecli.packages.special.utils import check_if_sqlitedotcommand
|
||||
|
||||
|
||||
def test_import_first_argument():
|
||||
|
@ -74,3 +75,16 @@ def test_indexes():
|
|||
{"type": "schema"},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_check_if_sqlitedotcommand():
|
||||
test_cases = [
|
||||
[".tables", True],
|
||||
[".BiNarY", True],
|
||||
["binary", False],
|
||||
[234, False],
|
||||
[".changes test! test", True],
|
||||
["NotDotcommand", False],
|
||||
]
|
||||
for command, expected_result in test_cases:
|
||||
assert check_if_sqlitedotcommand(command) == expected_result
|
||||
|
|
|
@ -260,3 +260,13 @@ def test_import_command(executor):
|
|||
"""
|
||||
assert result.exit_code == 0
|
||||
assert expected in "".join(result.output)
|
||||
|
||||
|
||||
def test_startup_commands(executor):
|
||||
m = LiteCli(liteclirc=default_config_file)
|
||||
assert m.startup_commands["commands"] == [
|
||||
"create table startupcommands(a text)",
|
||||
"insert into startupcommands values('abc')",
|
||||
]
|
||||
|
||||
# implement tests on executions of the startupcommands
|
||||
|
|
|
@ -15,7 +15,6 @@ metadata = {
|
|||
|
||||
@pytest.fixture
|
||||
def completer():
|
||||
|
||||
import litecli.sqlcompleter as sqlcompleter
|
||||
|
||||
comp = sqlcompleter.SQLCompleter()
|
||||
|
@ -367,17 +366,15 @@ def test_auto_escaped_col_names(completer, complete_event):
|
|||
Document(text=text, cursor_position=position), complete_event
|
||||
)
|
||||
)
|
||||
assert (
|
||||
result
|
||||
== [
|
||||
Completion(text="*", start_position=0),
|
||||
Completion(text="`ABC`", start_position=0),
|
||||
Completion(text="`insert`", start_position=0),
|
||||
Completion(text="id", start_position=0),
|
||||
]
|
||||
+ list(map(Completion, completer.functions))
|
||||
+ [Completion(text="`select`", start_position=0)]
|
||||
+ list(map(Completion, sorted(completer.keywords)))
|
||||
assert result == [
|
||||
Completion(text="*", start_position=0),
|
||||
Completion(text="`ABC`", start_position=0),
|
||||
Completion(text="`insert`", start_position=0),
|
||||
Completion(text="id", start_position=0),
|
||||
] + list(map(Completion, completer.functions)) + [
|
||||
Completion(text="select", start_position=0)
|
||||
] + list(
|
||||
map(Completion, sorted(completer.keywords))
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -94,11 +94,11 @@ def test_invalid_column_name(executor):
|
|||
@dbtest
|
||||
def test_unicode_support_in_output(executor):
|
||||
run(executor, "create table unicodechars(t text)")
|
||||
run(executor, u"insert into unicodechars (t) values ('é')")
|
||||
run(executor, "insert into unicodechars (t) values ('é')")
|
||||
|
||||
# See issue #24, this raises an exception without proper handling
|
||||
results = run(executor, u"select * from unicodechars")
|
||||
assert_result_equal(results, headers=["t"], rows=[(u"é",)])
|
||||
results = run(executor, "select * from unicodechars")
|
||||
assert_result_equal(results, headers=["t"], rows=[("é",)])
|
||||
|
||||
|
||||
@dbtest
|
||||
|
@ -106,9 +106,9 @@ def test_invalid_unicode_values_dont_choke(executor):
|
|||
run(executor, "create table unicodechars(t text)")
|
||||
# \xc3 is not a valid utf-8 char. But we can insert it into the database
|
||||
# which can break querying if not handled correctly.
|
||||
run(executor, u"insert into unicodechars (t) values (cast(x'c3' as text))")
|
||||
run(executor, "insert into unicodechars (t) values (cast(x'c3' as text))")
|
||||
|
||||
results = run(executor, u"select * from unicodechars")
|
||||
results = run(executor, "select * from unicodechars")
|
||||
assert_result_equal(results, headers=["t"], rows=[("\\xc3",)])
|
||||
|
||||
|
||||
|
@ -120,13 +120,13 @@ def test_multiple_queries_same_line(executor):
|
|||
{
|
||||
"title": None,
|
||||
"headers": ["'foo'"],
|
||||
"rows": [(u"foo",)],
|
||||
"rows": [("foo",)],
|
||||
"status": "1 row in set",
|
||||
},
|
||||
{
|
||||
"title": None,
|
||||
"headers": ["'bar'"],
|
||||
"rows": [(u"bar",)],
|
||||
"rows": [("bar",)],
|
||||
"status": "1 row in set",
|
||||
},
|
||||
]
|
||||
|
@ -369,8 +369,8 @@ def test_cd_command_current_dir(executor):
|
|||
|
||||
@dbtest
|
||||
def test_unicode_support(executor):
|
||||
results = run(executor, u"SELECT '日本語' AS japanese;")
|
||||
assert_result_equal(results, headers=["japanese"], rows=[(u"日本語",)])
|
||||
results = run(executor, "SELECT '日本語' AS japanese;")
|
||||
assert_result_equal(results, headers=["japanese"], rows=[("日本語",)])
|
||||
|
||||
|
||||
@dbtest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue