Skip to content

test : added unit tests for FilterPreset and SavedViewCreate Pydantic validators#1231

Open
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#1225
Open

test : added unit tests for FilterPreset and SavedViewCreate Pydantic validators#1231
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#1225

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #1225.

Summary of What Has Been Done:
Added 13 unit tests to testing/backend/unit/test_saved_views.py covering the Pydantic model validators in FilterPreset and SavedViewCreate from backend.secuscan.saved_views. The existing integration tests cover the HTTP routes but not the validator edge cases.

Changes Made:

  • FilterPreset defaults: severity defaults to all, sortMode defaults to severity, scanner defaults to all
  • FilterPreset.validate_sort_mode: all 4 valid modes pass; invalid mode raises ValueError
  • FilterPreset.validate_severity: all 6 valid severities pass; invalid severity raises ValueError
  • SavedViewCreate.strip_name: valid name passes, whitespace is trimmed, blank/whitespace-only raises ValidationError (min_length constraint fires for empty string, field_validator fires for whitespace-only)
  • SavedViewCreate.validate_filter_json: valid JSON passes, malformed JSON raises ValidationError

Impact it Made:
FilterPreset and SavedViewCreate are the input boundary for the saved-views API. Validator bugs could corrupt stored filter state. Direct unit tests catch regressions in validator logic without needing a full HTTP client.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

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.

test : add unit tests for FilterPreset and SavedViewCreate Pydantic validators

1 participant