Skip to content

Conversation

@leavesster
Copy link
Contributor

Summary

  • Change JSON comparison from string equality to dict equality
  • Prevents test failures due to JSON field ordering differences

Problem

Tests compared JSON as strings:

self.assertEqual(serialize_block_info, '{"session_id": "...", "job_id": "..."}')

This is fragile because:

  • JSON field order is not guaranteed
  • Python dict ordering changed in Python 3.7+
  • Different JSON libraries may produce different ordering

Solution

Parse JSON and compare as dicts:

from json import loads as json_loads

expected = {"session_id": "session_id_one", "job_id": "job_id_one", ...}
self.assertEqual(json_loads(serialize_block_info), expected)

Test Plan

  • All existing tests pass
  • Tests are now order-independent

String comparison of JSON output depends on field ordering, which can
vary across Python versions or JSON implementations. Comparing parsed
dicts is more robust.
Copilot AI review requested due to automatic review settings January 31, 2026 09:29
@coderabbitai
Copy link

coderabbitai bot commented Jan 31, 2026

Warning

Rate limit exceeded

@leavesster has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes fragile JSON comparison tests by comparing parsed dictionaries instead of raw JSON strings, eliminating test failures caused by JSON field ordering differences.

Changes:

  • Updated import to include loads as json_loads from the json module
  • Modified three test assertions to parse JSON strings and compare as dicts instead of direct string comparison
  • Added clarifying comments explaining the field order independence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leavesster leavesster changed the title fix: compare JSON as dicts instead of strings in test_data.py fix(oocana): compare JSON as dicts instead of strings in test_data.py Jan 31, 2026
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