Skip to content

Conversation

@kasya
Copy link
Collaborator

@kasya kasya commented Nov 16, 2025

Fix for equality checks with floating point values in backend tests.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Summary by CodeRabbit

  • Tests
    • Enhanced assertions for floating-point constants across multiple test modules to improve reliability and robustness.

Walkthrough

Two test files have been updated to replace direct floating-point equality assertions with tolerance-based comparisons using math.isclose(). The changes add import math and modify existing test assertions to accommodate floating-point representation differences while preserving test behavior.

Changes

Cohort / File(s) Summary
Floating-point comparison robustness in tests
backend/tests/apps/ai/agent/tools/rag/generator_test.py, backend/tests/apps/slack/common/question_detector_test.py
Added import math and replaced direct equality checks (==) with math.isclose() for TEMPERATURE constant assertions to tolerate floating-point representation differences

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Both changes follow an identical pattern (import math, update one assertion)
  • No production code modifications
  • Simple, repetitive test assertion updates with clear intent

Possibly related PRs

Suggested labels

backend, backend-tests

Suggested reviewers

  • arkid15r

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: converting equality checks to use math.isclose for floating-point comparison.
Description check ✅ Passed The description clearly relates to the changeset, explaining the fix addresses floating-point equality checks in backend tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-float-comparison

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68d7e5e and c6e8261.

📒 Files selected for processing (2)
  • backend/tests/apps/ai/agent/tools/rag/generator_test.py (2 hunks)
  • backend/tests/apps/slack/common/question_detector_test.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
backend/tests/apps/ai/agent/tools/rag/generator_test.py (1)
backend/apps/ai/agent/tools/rag/generator.py (1)
  • Generator (15-119)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run Code Scan
  • GitHub Check: Run CI Denendencies Scan
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (2)
backend/tests/apps/slack/common/question_detector_test.py (1)

3-3: LGTM! Correct approach for floating-point comparison.

Using math.isclose() instead of direct equality is the appropriate way to handle floating-point comparisons in Python, avoiding potential precision issues from binary representation of decimal numbers.

Also applies to: 186-186

backend/tests/apps/ai/agent/tools/rag/generator_test.py (1)

3-3: LGTM! Correct approach for floating-point comparison.

Using math.isclose() instead of direct equality properly handles floating-point representation differences and follows Python best practices for numeric comparisons.

Also applies to: 324-324


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 and usage tips.

@sonarqubecloud
Copy link

@kasya kasya marked this pull request as ready for review November 16, 2025 00:59
@kasya kasya requested a review from arkid15r as a code owner November 16, 2025 00:59
@arkid15r arkid15r enabled auto-merge November 16, 2025 00:59
@arkid15r arkid15r added this pull request to the merge queue Nov 16, 2025
Merged via the queue into main with commit 28ba425 Nov 16, 2025
28 checks passed
@arkid15r arkid15r deleted the fix-float-comparison branch November 16, 2025 01:11
mirnumaan pushed a commit to mirnumaan/Nest that referenced this pull request Nov 16, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 19, 2025
* add the aria-label

* fixed the code style, fixed by the formatter

* Handled the undefined repositoryName in aria-label.

* fix the white spaces

* Add aria-labels to interactive elements for WCAG 2.1 compliance

* Sync www-repopsitories (#2164)

* spelling fixes and tests

* sonar and code rabbit suggestions implemented

* json chunking and suggestions implemented

* code rabbit and sonar qube suggestions

* code rabbit suggestions

* suggestions implemented

* github advance security addressed

* tests fixed

* fixed tests

* Clean up backend/test_commands.py

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>

* Update docker-compose/local.yaml

* Nestbot MVP (#2113)

* Sync www-repopsitories (#2164)

* spelling fixes and tests

* sonar and code rabbit suggestions implemented

* json chunking and suggestions implemented

* code rabbit and sonar qube suggestions

* code rabbit suggestions

* suggestions implemented

* github advance security addressed

* tests fixed

* fixed tests

* Clean up backend/test_commands.py

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>

* Consolidate code commits

* Update cspell/custom-dict.txt

* Update docker-compose/local.yaml

* local yaml worder volume fix

* instance check

* poetry file updated

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>

* fixed the duplication error for chunks and context (#2343)

* Fix slack and duplication errors (#2352)

* fix slack and duplication errors

* code rabbit suggestions

* integrity error solved

* using set

* Update code

---------

Co-authored-by: Arkadii Yakovets <[email protected]>

* Response improvements and refactoring (#2407)

* improvements and refactoring

* added prompt checks and tests for it

* question detection refining (#2443)

* question detection refining

* sonar qube fixes

* fix tests

* Agentic rag (#2432)

* agentic rag

* spelling fixes

* code rabbit and sonar qube suggestions

* code rabbit suggestions

* refining

* fix test

* refining

* added question detectoor to nestbot mentions (#2473)

* Merge NestBot AI Assistant feature branch

* Update docker-compose/local.yaml

* Update backend/Makefile

* fix the white spaces

* Add aria-labels to interactive elements for WCAG 2.1 compliance

* Fix equality checks with floating point values (#2658)

* Edit in test cases for the new aira-label update

* More edits to make the test more unbreakable and few regex edits .

* Revert one change regards two seperate Contributors

* Regex check fix

* Global 10-second timeout and increased other mobile timeout to fix the  Mobile Safari flaky tests

---------

Co-authored-by: Dishant Miyani <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Kate Golovanova <[email protected]>
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.

3 participants