Skip to content

test : added edge case tests for parse_to_utc in time_utils - #2427

Closed
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2422
Closed

test : added edge case tests for parse_to_utc in time_utils#2427
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2422

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2422.

Summary of What Has Been Done:
Created a new test file testing/backend/unit/test_time_utils_parse_utc_edge_cases.py with 11 edge case tests for parse_to_utc() in backend/secuscan/time_utils.py.

The existing test_time_utils.py covers happy-path ISO 8601 formats only. This file adds tests for malformed inputs, None, empty strings, non-string types, and the 'now' literal.

Changes Made:

  • New file: testing/backend/unit/test_time_utils_parse_utc_edge_cases.py
  • Added TestParseToUtcEdgeCases class with 11 tests covering:
    • None input returns None
    • Empty string returns None
    • Whitespace-only string returns None
    • Garbage strings ("not-a-date", "hello world") return None
    • Integer Unix timestamps return UTC datetime
    • Float Unix timestamps return UTC datetime
    • 'now' literal returns current UTC time
    • List input converted to string and returns None
    • Boolean True treated as Unix timestamp (epoch + 1 second)
    • Boolean False treated as Unix timestamp (epoch)

Impact it Made:

  • Ensures parse_to_utc degrades gracefully on malformed input rather than raising unhandled exceptions
  • Prevents crashes when scan data contains garbage timestamps
  • Documents the behavior of non-string type inputs

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

@utksh1 utksh1 added area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label labels Aug 4, 2026
@utksh1

utksh1 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closing this PR as a duplicate of #2327, which is the earlier and broader submission for the same helper/test surface. Please continue any fixes in #2327 so the repository does not merge duplicate test files or split the coverage across competing PRs.

@utksh1 utksh1 closed this Aug 4, 2026
@utksh1 utksh1 added the gssoc:invalid Admin validation: invalid for GSSoC scoring label Aug 4, 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:invalid Admin validation: invalid 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 edge case tests for parse_to_utc in time_utils

2 participants