1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
# fmt: off
import pytest
import subprocess
import sys
from typing import List
from conftest import ShellTest
import os
from pathlib import Path
def test_missing_arg(shell):
test = (
ShellTest(shell)
.statement("SELECT 42")
.add_argument("-xyz")
)
result = test.run()
result.check_stderr("Unrecognized option")
result.check_stderr("xyz")
def test_headers(shell):
test = (
ShellTest(shell)
.statement("SELECT 42 as wilbur")
.add_argument("-csv", "-header")
)
result = test.run()
result.check_stdout("wilbur")
def test_no_headers(shell):
test = (
ShellTest(shell)
.statement("SELECT 42 as wilbur")
.add_argument("-csv", "-noheader")
)
result = test.run()
result.check_not_exist("wilbur")
def test_storage_version_latest(shell):
test = (
ShellTest(shell)
.statement("SELECT 42")
.add_argument("-storage_version", "latest")
)
result = test.run()
result.check_stdout("42")
def test_command(shell):
test = (
ShellTest(shell)
.add_argument("-c", "SELECT 42")
)
result = test.run()
result.check_stdout("42")
def test_version(shell):
test = (
ShellTest(shell)
.add_argument("-version")
)
result = test.run()
result.check_stdout("v")
def test_csv_options(shell):
test = (
ShellTest(shell)
.statement("SELECT 42 a, NULL b")
.add_argument("-csv", "-nullvalue", "MYNULL", "-separator", "MYSEP")
)
result = test.run()
result.check_stdout("42MYSEPMYNULL")
def test_echo(shell):
test = (
ShellTest(shell, ['-echo'])
.statement("SELECT 42;")
)
result = test.run()
result.check_stdout("SELECT 42")
def test_storage_version_error(shell):
test = (
ShellTest(shell)
.statement("SELECT 42")
.add_argument("-storage-version", "XXX")
)
result = test.run()
result.check_stderr("XXX")
# fmt: on
|