Skip to content

refactor(test_admin_audit_events): Test Passes with API 200 response #263

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

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

ashjorda
Copy link
Collaborator

Fix admin audit events test to handle empty results gracefully

Problem

The test_admin_audit_events.py test was failing with cryptic assertion errors (assert 0 == 3) instead of showing actual API error details. The test required exactly 3 events to pass, which failed when:

  • No admin audit events existed in the date range
  • API returned errors (400 Bad Request, permission issues, etc.)

Changes Made

1. Modified test success criteria

  • Before: Required exactly 3 events (assert len(three_events) == 3)
  • After: Test passes on successful API call (HTTP 200) regardless of result count

2. Improved error handling

  • Before: Generic assertion failures that masked actual API errors
  • After: Proper ApiError exception handling that shows:
    • HTTP status codes
    • Error messages
    • Webex tracking IDs
    • Full error details

3. Enhanced test resilience

  • Before: Tests failed completely when no events available
  • After: Tests gracefully skip when no data available (pytest.skip())
  • Validates event structure only when events exist

Benefits

  • ✅ Tests now pass when API works correctly (even with 0 results)
  • ✅ Shows detailed error information for debugging API issues
  • ✅ Distinguishes between API failures vs. empty result sets
  • ✅ Maintains validation logic when events are available
  • ✅ Follows same error handling patterns as other SDK tests

Test Behavior

  • API succeeds + has events: Validates event structure ✓
  • API succeeds + no events: Test passes ✓
  • API fails: Shows detailed error with tracking ID ✓

This makes the test more robust and provides better debugging information when issues occur.

@ashjorda ashjorda self-assigned this Aug 15, 2025
@Joezanini Joezanini merged commit 20c7d14 into main Aug 15, 2025
Copy link
Collaborator

@Joezanini Joezanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Work

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