Skip to content

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

Merged
utksh1 merged 3 commits into
utksh1:mainfrom
tmdeveloper007:#1225
Jun 24, 2026
Merged

test : added unit tests for FilterPreset and SavedViewCreate Pydantic validators#1231
utksh1 merged 3 commits 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.

@utksh1 utksh1 merged commit b66a5b0 into utksh1:main Jun 24, 2026
6 of 7 checks passed
@utksh1 utksh1 added the gssoc:approved Admin validation: approved for GSSoC scoring label Jun 24, 2026
utksh1 added a commit that referenced this pull request Jun 25, 2026
, #1234, #1232, #1231, #1230, #1229, #1228, #1222, #1221, #1254, #1252, #1251, #1250, #1242, #1255, #1090, #1097, #1112)

Reverting all PR merges performed during this session to restore repository
to pre-session state. This reverts commits:
- e376276 (#1255)
- 18e5101 (#1222)
- e516dd5 (#1230)
- be400fa (#1235)
- d522e9a (#1243)
- bc0b1cd (#1090)
- de56660 (#1097)
- c2a5a53 (#1112)
- eb30d33 (#1254)
- f2a67f7 (#1250)
- 6579112 (#1251)
- 8751d92 (#1252)
- 3ebc935 (#1221)
- 6f5a936 (#1228)
- da15da4 (#1229)
- b66a5b0 (#1231)
- 775c5c2 (#1232)
- b529ddb (#1234)
- 965b001 (#1241)
- d46e573 (#1242)
- dd09955 (#1240)

All PRs are also being reopened and gssoc labels removed.
@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label area:backend Backend API, database, or service work gssoc:approved Admin validation: approved for GSSoC scoring and removed gssoc:approved Admin validation: approved for GSSoC scoring labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work gssoc:approved Admin validation: approved for GSSoC scoring level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for FilterPreset and SavedViewCreate Pydantic validators

2 participants