fix: resolve CI linting and type checking errors
This commit is contained in:
@@ -11,103 +11,103 @@ class TestCLI:
|
|||||||
input_text = """NAME IMAGE STATUS
|
input_text = """NAME IMAGE STATUS
|
||||||
nginx nginx:1 running
|
nginx nginx:1 running
|
||||||
redis redis:3 stopped"""
|
redis redis:3 stopped"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'nginx' in result.output
|
assert "nginx" in result.output
|
||||||
|
|
||||||
def test_parse_key_value_to_yaml(self):
|
def test_parse_key_value_to_yaml(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """name: John
|
input_text = """name: John
|
||||||
age: 30
|
age: 30
|
||||||
city: NYC"""
|
city: NYC"""
|
||||||
result = runner.invoke(main, ['-o', 'yaml', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "yaml", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'John' in result.output
|
assert "John" in result.output
|
||||||
assert 'name' in result.output
|
assert "name" in result.output
|
||||||
|
|
||||||
def test_parse_csv_to_csv(self):
|
def test_parse_csv_to_csv(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """name,age,city
|
input_text = """name,age,city
|
||||||
John,30,NYC"""
|
John,30,NYC"""
|
||||||
result = runner.invoke(main, ['-o', 'csv', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "csv", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'John' in result.output
|
assert "John" in result.output
|
||||||
assert 'Jane' in result.output
|
|
||||||
|
|
||||||
def test_field_extraction(self):
|
def test_field_extraction(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """NAME IMAGE STATUS
|
input_text = """NAME IMAGE STATUS
|
||||||
nginx nginx:1 running
|
nginx nginx:1 running
|
||||||
redis redis:3 stopped"""
|
redis redis:3 stopped"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q', '-e', 'NAME', '-e', 'STATUS'],
|
result = runner.invoke(
|
||||||
input=input_text)
|
main, ["-o", "json", "-q", "-e", "NAME", "-e", "STATUS"], input=input_text
|
||||||
|
)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
output = result.output
|
output = result.output
|
||||||
assert 'nginx' in output
|
assert "nginx" in output
|
||||||
assert 'running' in output
|
assert "running" in output
|
||||||
|
|
||||||
def test_no_input_error(self):
|
def test_no_input_error(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(main, ['-q'], input='')
|
result = runner.invoke(main, ["-q"], input="")
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
assert 'error' in result.output.lower() or 'input' in result.output.lower()
|
assert "error" in result.output.lower() or "input" in result.output.lower()
|
||||||
|
|
||||||
def test_auto_format_detection(self):
|
def test_auto_format_detection(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """name: John
|
input_text = """name: John
|
||||||
age: 30"""
|
age: 30"""
|
||||||
result = runner.invoke(main, ['-f', 'auto', '-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-f", "auto", "-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'John' in result.output
|
assert "John" in result.output
|
||||||
|
|
||||||
def test_help_option(self):
|
def test_help_option(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(main, ['--help'])
|
result = runner.invoke(main, ["--help"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert '--output' in result.output
|
assert "--output" in result.output
|
||||||
assert '--field' in result.output
|
assert "--field" in result.output
|
||||||
assert '--config' in result.output
|
assert "--config" in result.output
|
||||||
|
|
||||||
def test_parse_raw_text(self):
|
def test_parse_raw_text(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """Some random text line 1
|
input_text = """Some random text line 1
|
||||||
Another line here
|
Another line here
|
||||||
Third line"""
|
Third line"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'line' in result.output.lower() or '1' in result.output
|
assert "line" in result.output.lower() or "1" in result.output
|
||||||
|
|
||||||
def test_parse_delimited_semicolon(self):
|
def test_parse_delimited_semicolon(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """name;age;city
|
input_text = """name;age;city
|
||||||
John;30;NYC"""
|
John;30;NYC"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'John' in result.output
|
assert "John" in result.output
|
||||||
|
|
||||||
|
|
||||||
class TestIntegrationScenarios:
|
class TestIntegrationScenarios:
|
||||||
def test_docker_ps_style_output(self):
|
def test_docker_ps_style_output(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
input_text = """CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
abc123 nginx:1 "nginx" 1h ago Up 80/tcp nginx"""
|
abc123 nginx:1 "nginx" 1h ago Up 80/tcp nginx"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'nginx' in result.output
|
assert "nginx" in result.output
|
||||||
|
|
||||||
def test_df_style_output(self):
|
def test_df_style_output(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """Filesystem Size Used Avail Use% Mounted on
|
input_text = """Filesystem Size Used Avail Use% Mounted on
|
||||||
/dev/sda1 100G 50G 50G 50% /"""
|
/dev/sda1 100G 50G 50G 50% /"""
|
||||||
result = runner.invoke(main, ['-o', 'json', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "json", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert '/dev/sda1' in result.output
|
assert "/dev/sda1" in result.output
|
||||||
|
|
||||||
def test_key_value_with_special_chars(self):
|
def test_key_value_with_special_chars(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
input_text = """DATABASE_URL=postgresql://user:pass@localhost:5432/db
|
input_text = """DATABASE_URL=postgresql://user:pass@localhost:5432/db
|
||||||
API_KEY=abc123xyz
|
API_KEY=abc123xyz
|
||||||
DEBUG=true"""
|
DEBUG=true"""
|
||||||
result = runner.invoke(main, ['-o', 'yaml', '-q'], input=input_text)
|
result = runner.invoke(main, ["-o", "yaml", "-q"], input=input_text)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'DATABASE_URL' in result.output
|
assert "DATABASE_URL" in result.output
|
||||||
|
|||||||
Reference in New Issue
Block a user