Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: do not store errored requests into output file #73

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/offat/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def start():
action='store_true',
help='Enable SSL Verification',
)
parser.add_argument(
'-cf',
'--capture-failed',
dest='capture_failed',
action='store_true',
help='Captures failed requests due to any exceptions into output file',
)
args = parser.parse_args()

# convert req headers str to dict
Expand Down Expand Up @@ -146,6 +153,7 @@ def start():
test_data_config=test_data_config,
proxies=args.proxies_list,
ssl=args.ssl,
capture_failed=args.capture_failed,
)


Expand Down
11 changes: 10 additions & 1 deletion src/offat/report/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,21 @@ def save_report(report_path: str | None, report_file_content: str | Table | None

@staticmethod
def generate_report(
results: list[dict], report_format: str | None, report_path: str | None
results: list[dict],
report_format: str | None,
report_path: str | None,
capture_failed: bool = False,
):
"""main function used to generate report"""
if report_path:
report_format = report_path.split('.')[-1]

# do not store errored results if `capture_failed` is False
if not capture_failed:
results = list(
filter(lambda result: result.get('error', True) == False, results)
)

formatted_results = ReportGenerator.handle_report_format(
results=results, report_format=report_format
)
Expand Down
1 change: 1 addition & 0 deletions src/offat/tester/tester_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def generate_and_run_tests(
proxies: list[str] | None = None,
test_data_config: dict | None = None,
ssl: bool = False,
capture_failed: bool = False,
):
'''
Generates and runs tests for provied OAS/Swagger file.
Expand Down