Skip to content

test: source returned regardless of their status#996

Merged
dbasunag merged 2 commits intoopendatahub-io:mainfrom
fege:all_catalog
Jan 8, 2026
Merged

test: source returned regardless of their status#996
dbasunag merged 2 commits intoopendatahub-io:mainfrom
fege:all_catalog

Conversation

@fege
Copy link
Copy Markdown
Contributor

@fege fege commented Jan 8, 2026

Description

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Summary by CodeRabbit

  • Tests
    • Added a new test ensuring the sources endpoint returns all sources regardless of the enabled flag, validating presence of both enabled and disabled items and consistent total counts.
    • Strengthened existing source-status tests with clearer descriptions and expanded assertions to better surface status and error conditions.

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 8, 2026

The following are automatically added/executed:

  • PR size label.
  • Run pre-commit
  • Run tox
  • Add PR author as the PR assignee
  • Build image based on the PR

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To Cherry-pick a merged PR /cherry-pick <target_branch_name> to the PR. If <target_branch_name> is valid,
    and the current PR is merged, a cherry-picked PR would be created and linked to the current PR.
  • To build and push image to quay, add /build-push-pr-image in a comment. This would create an image with tag
    pr-<pr_number> to quay repository. This image tag, however would be deleted on PR merge or close action.
Supported labels

{'/lgtm', '/cherry-pick', '/wip', '/build-push-pr-image', '/verified', '/hold'}

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Shortened class docstring and added a new pytest to the sources endpoint tests that asserts the endpoint returns both enabled and disabled sources (status and counts); other existing source-status-related tests' docstrings were refined.

Changes

Cohort / File(s) Summary
Sources endpoint tests
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py
Shortened TestSourcesEndpoint docstring. Added test_sources_endpoint_returns_all_sources_regardless_of_enabled_field decorated with @pytest.mark.parametrize(..., indirect=True) and @pytest.mark.sanity; verifies endpoint returns multiple items, asserts presence of enabled ("available") and disabled ("disabled") sources, validates total counts and logs results. Refined/updated docstrings on other related tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a test that verifies sources are returned regardless of their enabled/disabled status.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 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 ebf70fc and 5e8c653.

📒 Files selected for processing (1)
  • tests/model_registry/model_catalog/metadata/test_sources_endpoint.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py (4)
tests/model_registry/model_catalog/conftest.py (2)
  • enabled_model_catalog_config_map (43-90)
  • model_catalog_rest_url (405-414)
tests/model_registry/model_catalog/metadata/conftest.py (1)
  • disabled_catalog_source (14-52)
tests/model_registry/conftest.py (1)
  • model_registry_rest_headers (399-400)
tests/model_registry/utils.py (1)
  • execute_get_command (730-738)
🪛 Ruff (0.14.10)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py

82-82: Unused method argument: enabled_model_catalog_config_map

(ARG002)


83-83: Unused method argument: disabled_catalog_source

(ARG002)

🔇 Additional comments (3)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py (3)

15-15: LGTM! Clear and concise class docstring.

The simplified docstring adequately describes the test class purpose.


25-25: LGTM! Issue tracking added to test docstrings.

The addition of RHOAIENG-41849 identifiers improves traceability.

Also applies to: 50-50


78-108: Test logic looks good, but address status value assumption on line 103.

The test correctly validates that the sources endpoint returns both enabled and disabled sources. The fixture parameters flagged by static analysis are actually necessary for test setup (they modify state via side effects), so those warnings are false positives.

However, line 103's assertion assumes all sources must have status "available" or "disabled". Based on the validate_source_status utility function (which documents "error" as a valid status value), sources could potentially have additional statuses beyond these two. If any source has status "error" or another value, this assertion would fail unexpectedly because such sources would not be counted in either enabled_sources or disabled_sources.

Either filter for the complete set of expected statuses explicitly, or add verification that no sources have unexpected statuses before this assertion.


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.

Copy link
Copy Markdown
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: 2

🤖 Fix all issues with AI agents
In @tests/model_registry/model_catalog/metadata/test_sources_endpoint.py:
- Around line 49-56: The test should avoid KeyError by using safe dict access
for the error field: replace direct access of source["error"] with
source.get("error") when computing error_value (in the loop over enabled_sources
that calls validate_source_status and checks error_value), and keep the existing
assertion logic and message but reference the retrieved error_value from get to
ensure missing keys are handled gracefully.
- Around line 57-71: The test may raise a KeyError by accessing
disabled_catalog["error"]; change to safe access using
disabled_catalog.get("error") when reading the error field (and update the
assertion accordingly) so the check in validate_source_status and the subsequent
assertion use the .get() accessor; keep references to disabled_catalog,
validate_source_status and LOGGER unchanged.
🧹 Nitpick comments (1)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py (1)

38-47: Consider handling unexpected status values more explicitly.

The current logic assumes all sources have a status of either "available" or "disabled". If a source has a missing status field (None) or an unexpected value, it will be excluded from both lists, causing the assertion at lines 45-47 to fail with a generic message.

Consider adding explicit handling to make debugging easier if unexpected status values are encountered.

🛡️ Proposed refactor for better error handling
 # Split sources by status
 enabled_sources = [item for item in items if item.get("status") == "available"]
 disabled_sources = [item for item in items if item.get("status") == "disabled"]
+unexpected_sources = [
+    item for item in items 
+    if item.get("status") not in ["available", "disabled"]
+]
 
 # Verify we have both enabled and disabled sources
 assert enabled_sources, "Expected at least one enabled source"
 assert disabled_sources, "Expected at least one disabled source"
+assert not unexpected_sources, (
+    f"Found sources with unexpected status values: "
+    f"{[{'id': s.get('id'), 'status': s.get('status')} for s in unexpected_sources]}"
+)
 assert len(enabled_sources) + len(disabled_sources) == len(items), (
     "All sources should have either 'available' or 'disabled' status"
 )
📜 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 7366095 and ebf70fc.

📒 Files selected for processing (1)
  • tests/model_registry/model_catalog/metadata/test_sources_endpoint.py
🧰 Additional context used
🪛 Ruff (0.14.10)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py

21-21: Unused method argument: enabled_model_catalog_config_map

(ARG002)

🔇 Additional comments (3)
tests/model_registry/model_catalog/metadata/test_sources_endpoint.py (3)

15-15: LGTM!

The updated class docstring is clear and concise.


26-37: LGTM!

The test setup and initial validation are clear and correct.


17-25: No action needed. The enabled_model_catalog_config_map fixture is required for test setup. Although the fixture parameter is not directly referenced in the test code, it is essential for establishing preconditions: the fixture enables all catalogs in the default model catalog ConfigMap as part of its initialization. The test subsequently validates source status/error fields with this setup in place. This is a standard pytest pattern where fixtures are used for their side effects (setup/teardown) rather than for their return values.

Comment thread tests/model_registry/model_catalog/metadata/test_sources_endpoint.py Outdated
Comment thread tests/model_registry/model_catalog/metadata/test_sources_endpoint.py Outdated
@github-actions github-actions Bot added size/s and removed size/m labels Jan 8, 2026
@dbasunag dbasunag enabled auto-merge (squash) January 8, 2026 15:55
Copy link
Copy Markdown
Contributor

@sheltoncyril sheltoncyril left a comment

Choose a reason for hiding this comment

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

/lgtm but would have preferred a shorter name for the method

@dbasunag dbasunag merged commit f206021 into opendatahub-io:main Jan 8, 2026
9 checks passed
@fege fege deleted the all_catalog branch January 8, 2026 16:02
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 8, 2026

Status of building tag latest: success.
Status of pushing tag latest to image registry: success.

mwaykole pushed a commit to mwaykole/opendatahub-tests that referenced this pull request Jan 23, 2026
* test: source returned regardless of their status

* fix: add single test to retrieve disabled and enabled sources
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.

4 participants