Skip to content

Commit

Permalink
tests with runner.invoke 1st pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanpulver committed Jun 28, 2024
1 parent 2cce331 commit 91316f8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
import os
import shutil
import tempfile
Expand Down Expand Up @@ -69,6 +70,8 @@ def setUp(self):
self.runner = CliRunner(mix_stderr=False)
self.output_options = ['screen', 'text', 'json', 'bare']
self.dirname = os.path.dirname(__file__)
# Set up logging to capture debug output for tests
logging.basicConfig(level=logging.DEBUG, format='%(name)s - %(levelname)s - %(message)s')

def test_command_line_interface(self):
runner = CliRunner()
Expand Down Expand Up @@ -513,4 +516,22 @@ def test_license_with_file(self, fetch_database_url):
test_filename = os.path.join(dirname, "reqs_4.txt")
result = self.runner.invoke(cli.cli, ['license', '--key', 'foo', '--file', test_filename])
print(result.stdout)
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.exit_code, 0)

@patch('builtins.input', lambda *args: '')
def test_debug_flag(self):
result = self.runner.invoke(cli.cli, ['--debug', 'scan'])
print(result.output)
assert "for known security issues using default" in result.output

@patch('builtins.input', lambda *args: '')
def test_debug_flag_with_value_1(self):
result = self.runner.invoke(cli.cli, ['--debug', '1', 'scan'])
print(result.output)
assert "for known security issues using default" in result.output

@patch('builtins.input', lambda *args: '')
def test_debug_flag_with_value_true(self):
result = self.runner.invoke(cli.cli, ['--debug', 'true', 'scan'])
print(result.output)
assert "for known security issues using default" in result.output

0 comments on commit 91316f8

Please sign in to comment.