Skip to content

Commit 07578ec

Browse files
committed
Remove console report
1 parent 84cba87 commit 07578ec

5 files changed

Lines changed: 12 additions & 44 deletions

File tree

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,17 @@ You can find complete examples at [scanapi-examples][scanapi-examples]!
7474

7575
```bash
7676
$ scanapi --help
77-
Usage: scanapi [OPTIONS]
77+
Usage: scanapi [OPTIONS] [SPEC_PATH]
7878

7979
Automated Testing and Documentation for your REST API.
8080

8181
Options:
82-
-s, --spec-path PATH
8382
-o, --output-path PATH
8483
-c, --config-path PATH
85-
-r, --reporter [console|markdown|html]
84+
-r, --reporter [html|markdown]
8685
-t, --template PATH
87-
--log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
88-
--help Show this message and exit.
86+
-ll, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
87+
-h, --help Show this message and exit.
8988
```
9089

9190
### API Specification Keys
@@ -266,7 +265,7 @@ If you want to configure the ScanAPI with a file, you can create a `.scanapi.yam
266265
```yaml
267266
spec_path: my_path/api.yaml
268267
output_path: my_path/scanapi-report.md
269-
reporter: console
268+
reporter: markdown
270269
```
271270

272271
### Hiding sensitive information

scanapi/main.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
from scanapi.scan import scan
55
from scanapi.settings import settings
66

7+
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
78

8-
@click.command()
9-
@click.option("-s", "--spec-path", "spec_path", type=click.Path(exists=True))
9+
10+
@click.command(context_settings=CONTEXT_SETTINGS)
11+
@click.argument("spec_path", type=click.Path(exists=True), required=False)
1012
@click.option("-o", "--output-path", "output_path", type=click.Path())
1113
@click.option("-c", "--config-path", "config_path", type=click.Path(exists=True))
12-
@click.option(
13-
"-r", "--reporter", "reporter", type=click.Choice(["console", "markdown", "html"])
14-
)
14+
@click.option("-r", "--reporter", "reporter", type=click.Choice(["html", "markdown"]))
1515
@click.option("-t", "--template", "template", type=click.Path(exists=True))
1616
@click.option(
17+
"-ll",
1718
"--log-level",
1819
"log_level",
1920
type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]),

scanapi/reporter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ def write(self, responses):
2828

2929
content = self._render_content(loader, template_path, responses)
3030

31-
if self.reporter == "console":
32-
print(f"\n{content}")
33-
return
34-
3531
if self.output_path is None:
3632
outputs = {"html": "scanapi-report.html", "markdown": "scanapi-report.md"}
3733
self.output_path = outputs.get(self.reporter) or "scanapi-report"

scanapi/templates/console.jinja

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/unit/test_reporter.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,7 @@
77
]
88

99

10-
class TestConsoleReport:
11-
@pytest.fixture
12-
def mocked_print(self, mocker):
13-
return mocker.patch("builtins.print")
14-
15-
def test_should_print(self, mocker, mocked_print):
16-
console_reporter = Reporter(None, "console")
17-
console_reporter.write(fake_responses)
18-
19-
expected_content = "\n".join(
20-
(
21-
"ScanAPI Report: Console",
22-
"=======================",
23-
"",
24-
"GET http://test.com - 200",
25-
"",
26-
)
27-
)
28-
29-
mocked_print.assert_called_once_with(f"\n{expected_content}")
30-
31-
32-
class TestReporterOtherThanConsole:
10+
class TestReporter:
3311
@pytest.fixture
3412
def mocked__render_content(self, mocker):
3513
return mocker.patch("scanapi.reporter.Reporter._render_content")

0 commit comments

Comments
 (0)