Skip to content

test: use synthetic coordinates in mocked weather test - #105

Merged
IceCodeNew merged 2 commits into
masterfrom
codex/fix-synthetic-weather-test
Jul 23, 2026
Merged

test: use synthetic coordinates in mocked weather test#105
IceCodeNew merged 2 commits into
masterfrom
codex/fix-synthetic-weather-test

Conversation

@IceCodeNew

@IceCodeNew IceCodeNew commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace real-world coordinates in a mocked Open-Meteo test with neutral synthetic values
  • preserve the mocked payload and assertions unchanged

Context

This follows up on the valid post-merge CodeRabbit finding in #99:
#99 (comment)

The test does not depend on geography, so retaining real location coordinates added unnecessary private-data risk.

Verification

  • mise exec -- prek run --all-files
  • mise exec -- uv run --with pytest --with pytest-cov -- pytest -q --cov --cov-branch --cov-report=xml
  • 907 tests passed
  • line coverage: 99.87%
  • branch coverage: 99.56%

Summary by CodeRabbit

  • Tests
    • Updated weather enrichment rejection tests to use neutral coordinates while preserving validation of invalid upstream payload handling.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d04d8e6-3926-4e11-86e6-4d6bc6e37f29

📥 Commits

Reviewing files that changed from the base of the PR and between ef21870 and 36a6b6b.

📒 Files selected for processing (1)
  • tests/test_weather_context.py

📝 Walkthrough

Walkthrough

Two Open-Meteo enrichment rejection tests now pass (1, 2) as latitude and longitude while retaining their existing forecast dates and assertions.

Changes

Weather enrichment tests

Layer / File(s) Summary
Update rejection test coordinates
tests/test_weather_context.py
The future and current enrichment rejection tests now call _fetch_air_quality_and_allergen with coordinates (1, 2) and retain their invalid-payload assertions.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: replacing real coordinates with synthetic ones in a mocked weather test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-synthetic-weather-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.82%. Comparing base (ef21870) to head (36a6b6b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #105   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files          86       86           
  Lines        9470     9470           
  Branches      563      563           
=======================================
  Hits         9453     9453           
  Misses         12       12           
  Partials        5        5           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@IceCodeNew

Copy link
Copy Markdown
Owner Author

/agentic_review

@qodo-code-review

qodo-code-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 46 rules

Grey Divider


Remediation recommended

1. Partial coord sanitization ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The PR replaces real-world coordinates only in
test_open_meteo_current_enrichment_rejects_non_object_payload, but the adjacent mocked Open-Meteo
enrichment test still uses 39.9/116.3 despite not depending on geography, so the test-data hygiene
change is applied inconsistently.
Code

tests/test_weather_context.py[R685-686]

+                1,
+                2,
Relevance

⭐⭐⭐ High

Team has accepted replacing real lat/long in tests with synthetic values to avoid leaking location
data.

PR-#89

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The current-enrichment test was updated to pass (1, 2) while still using MockTransport, but the
neighboring future-enrichment test is also fully mocked and still passes the original `(39.9,
116.3)` coordinates, demonstrating the sanitization wasn’t applied consistently.

tests/test_weather_context.py[644-657]
tests/test_weather_context.py[675-688]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The PR changes one mocked Open-Meteo test to use synthetic coordinates, but another mocked Open-Meteo enrichment test in the same area still passes real-world coordinates (39.9/116.3). This leaves inconsistent test fixture hygiene and undermines the PR’s stated intent.

### Issue Context
Both tests use `httpx.MockTransport` and do not rely on latitude/longitude values for assertions, so coordinates can be neutral/synthetic consistently.

### Fix Focus Areas
- tests/test_weather_context.py[644-657]
- tests/test_weather_context.py[675-688]

### Suggested change
Update the remaining `_fetch_air_quality_and_allergen(39.9, 116.3, ...)` call in the adjacent mocked test to use the same synthetic coordinates (or define a shared `TEST_LAT/TEST_LON` constant used by both tests).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread tests/test_weather_context.py
@IceCodeNew

Copy link
Copy Markdown
Owner Author

/agentic_review

@IceCodeNew
IceCodeNew marked this pull request as ready for review July 23, 2026 09:01
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 36a6b6b

@IceCodeNew
IceCodeNew marked this pull request as draft July 23, 2026 09:05
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Tests: replace real Open‑Meteo coordinates with synthetic values in mocked tests

🧪 Tests 🕐 Less than 5 minutes

Grey Divider

AI Description

• Replace real-world latitude/longitude in Open‑Meteo mocked tests with synthetic coordinates.
• Keep mocked payloads and assertions unchanged to preserve behavior coverage.
• Reduce private-data risk in test fixtures without affecting test intent.
Diagram

graph TD
  A["tests/test_weather_context.py"] --> B["OpenMeteoProvider"] --> C["_fetch_air_quality_and_allergen"] --> D["Mocked HTTP client"] --> E{{"Open‑Meteo API (mocked)"}}
Loading
High-Level Assessment

The chosen approach (swap real coordinates for neutral synthetic constants) is the simplest and best fit because the tests do not depend on geography; no more complex abstraction is warranted for two call sites.

Files changed (1) +4 / -4

Tests (1) +4 / -4
test_weather_context.pySanitize mocked Open‑Meteo test coordinates +4/-4

Sanitize mocked Open‑Meteo test coordinates

• Replaces hard-coded real-world latitude/longitude arguments passed to '_fetch_air_quality_and_allergen' with synthetic values in two Open‑Meteo enrichment rejection tests. The mocked responses and assertions remain unchanged, preserving test coverage while removing unnecessary real location data.

tests/test_weather_context.py

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 36a6b6b

@IceCodeNew
IceCodeNew marked this pull request as ready for review July 23, 2026 09:07
@IceCodeNew
IceCodeNew merged commit 1f78f9d into master Jul 23, 2026
18 checks passed
@IceCodeNew
IceCodeNew deleted the codex/fix-synthetic-weather-test branch July 23, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant