Skip to content

Add sanitization-based assertions for locale-specific timing text comparisons#303

Merged
jy95 merged 1 commit intomainfrom
jy95-patch-1
Jan 7, 2026
Merged

Add sanitization-based assertions for locale-specific timing text comparisons#303
jy95 merged 1 commit intomainfrom
jy95-patch-1

Conversation

@jy95
Copy link
Owner

@jy95 jy95 commented Jan 7, 2026

Summary by CodeRabbit

  • Tests
    • Enhanced timing event test validation with improved assertion logic and locale-specific text comparisons for greater robustness.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

A single test file has been refactored to replace inline assertion logic with locale-specific helper methods and a new sanitization utility. The changes introduce expectedSingleDayText() and multipleDaysText() methods to centralize expected text mappings, alongside a sanitize() helper that normalizes text for robust cross-locale comparisons.

Changes

Cohort / File(s) Summary
Test Assertion Refactor
common/src/test/java/io/github/jy95/fds/translators/AbstractTimingEventTest.java
Added new locale-specific helper methods (expectedSingleDayText(), multipleDaysText()) and a sanitize() utility to normalize text before comparison. Replaced inlined assertion logic and direct assertTrue() calls with sanitized exact string equality checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #302: Refactors locale-specific test assertions in a separate test class using the same sanitization and helper method pattern, indicating a coordinated testing improvement effort across the codebase.

Poem

🐰 A test that once sprawled without care,
Now springs forth with helpers so fair—
Sanitized text, locale-aware,
Makes assertions both robust and rare! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: introducing sanitization-based assertions for locale-specific timing text comparisons in the test file.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@codacy-production
Copy link

codacy-production bot commented Jan 7, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (f4ee78b) 1582 1582 100.00%
Head commit (82d088c) 3164 (+1582) 3164 (+1582) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#303) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
common/src/test/java/io/github/jy95/fds/translators/AbstractTimingEventTest.java (1)

74-96: Consider adding unit tests for the sanitize method.

The sanitization logic is well-documented and correctly implements normalization for CLDR variations. However, since this utility method is critical to test correctness, consider adding dedicated unit tests to verify its behavior with various inputs (null, empty string, different Unicode characters, edge cases).

Example test cases to consider
// Example structure (not a diff, just illustrative)
@Test
void testSanitizeHandlesNarrowNoBreakSpace() {
    assertEquals("Jan 1 2024", sanitize("Jan\u202F1\u202F2024"));
}

@Test
void testSanitizeRemovesPunctuation() {
    assertEquals("Jan 1 2024", sanitize("Jan. 1, 2024"));
}

@Test
void testSanitizeHandlesNull() {
    assertEquals("", sanitize(null));
}
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4ee78b and 82d088c.

📒 Files selected for processing (1)
  • common/src/test/java/io/github/jy95/fds/translators/AbstractTimingEventTest.java
⏰ 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: Codacy Static Code Analysis
  • GitHub Check: submit-pypi
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (4)
common/src/test/java/io/github/jy95/fds/translators/AbstractTimingEventTest.java (4)

31-33: LGTM! Improved test resilience.

The sanitization approach on both actual and expected values makes the test more robust against CLDR formatting variations while preserving semantic correctness checks.


39-48: LGTM! Clean locale mapping.

The centralized expected-value mapping improves maintainability. The locale-specific strings appear correct for their respective formatting conventions.


55-57: LGTM! Consistent with testSingle approach.

The changes maintain consistency with the single-day test pattern and correctly apply sanitization.


63-72: LGTM! Correct list formatting for multiple locales.

The locale-specific list formatting (conjunctions and separators) appears correct for each supported language.

@jy95 jy95 changed the title Update AbstractTimingEventTest.java Add sanitization-based assertions for locale-specific timing text comparisons Jan 7, 2026
@jy95 jy95 merged commit 1d36283 into main Jan 7, 2026
20 checks passed
@jy95 jy95 deleted the jy95-patch-1 branch January 7, 2026 23:52
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.

1 participant