Skip to content

Improve test coverage for capec_map_enricher and add edge case handling#2881

Merged
sydseter merged 2 commits intoOWASP:masterfrom
theanand108:edge-tests-clean
Apr 26, 2026
Merged

Improve test coverage for capec_map_enricher and add edge case handling#2881
sydseter merged 2 commits intoOWASP:masterfrom
theanand108:edge-tests-clean

Conversation

@theanand108
Copy link
Copy Markdown
Contributor

Summary

This PR improves test coverage for capec_map_enricher.py by adding edge case tests and handling previously untested scenarios. It also includes formatting fixes to satisfy linting requirements.

Changes

  • Added unit tests for:

    • YAML loading edge cases (empty file, parsing errors, generic exceptions)
    • JSON loading failure scenarios
    • Invalid CAPEC IDs and metadata handling
    • Argument parsing exceptions
    • Main function edge cases (default paths, output handling, save failure)
  • Improved robustness of:

    • Improved coverage for capec_map_enricher.py from ~83% to ~93%
    • load_yaml_file by handling empty and exception cases
    • main flow for better error handling
  • Applied formatting fixes using:

    • black (line length 120)
    • flake8 compliance

Result

  • Increased reliability and coverage of capec_map_enricher.py
  • All tests passing locally
  • Linting and formatting checks passing

This helps ensure stability when processing malformed or unexpected input data.

AI Disclosure

Some assistance from AI tools was used for brainstorming edge cases and improving test coverage. All changes were reviewed, validated, and tested manually.

Affirmation

I confirm that this contribution follows the project guidelines and that I have tested all changes locally.

@sydseter sydseter merged commit 849f0cb into OWASP:master Apr 26, 2026
9 checks passed
@theanand108 theanand108 deleted the edge-tests-clean branch April 26, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants