[IQE-3809] Update default for ibutsu source#102
Conversation
Reviewer's GuideAdjusts the default handling of the ibutsu source CLI option so that the effective default comes from the IBUTSU_SOURCE environment variable or falls back to 'local', and adds tests to validate this behavior. Sequence diagram for resolving ibutsu_source defaultsequenceDiagram
actor User
participant Pytest as PytestRunner
participant Plugin as PytestIbutsuPlugin
participant Env as Environment
User->>Pytest: run pytest (no --ibutsu-source)
Pytest->>Plugin: call pytest_addoption(parser)
Plugin->>Env: read IBUTSU_SOURCE
alt IBUTSU_SOURCE is set
Env-->>Plugin: value from IBUTSU_SOURCE
Plugin-->>Pytest: register ibutsu_source option (default = env value)
else IBUTSU_SOURCE is not set
Env-->>Plugin: null
Plugin-->>Pytest: register ibutsu_source option (default = local)
end
Pytest-->>User: execute tests with resolved ibutsu_source
Flow diagram for ibutsu_source default resolutionflowchart TD
A[Start pytest] --> B{--ibutsu-source provided?}
B -->|Yes| C[Use CLI ibutsu_source value]
B -->|No| D{IBUTSU_SOURCE env set?}
D -->|Yes| E[Use IBUTSU_SOURCE env value]
D -->|No| F[Use local as default]
C --> G[Run tests]
E --> G
F --> G
G --> H[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider handling the case where IBUTSU_SOURCE is set to an empty string so that the plugin still falls back to the 'local' default rather than treating an empty value as a valid source.
- It may be clearer to centralize the ibutsu_source resolution logic (CLI arg vs env vs 'local') into a small helper function, so the precedence rules are encapsulated and easier to adjust in the future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where IBUTSU_SOURCE is set to an empty string so that the plugin still falls back to the 'local' default rather than treating an empty value as a valid source.
- It may be clearer to centralize the ibutsu_source resolution logic (CLI arg vs env vs 'local') into a small helper function, so the precedence rules are encapsulated and easier to adjust in the future.
## Individual Comments
### Comment 1
<location> `tests/test_plugin.py:116-124` </location>
<code_context>
IbutsuPlugin.from_config(test_config)
+def test_ibutsu_source_default_when_unset(
+ isolate_ibutsu_env_vars: None, pytester: pytest.Pytester
+):
+ """Test ibutsu_source is 'local' when neither --ibutsu-source nor IBUTSU_SOURCE is set."""
+ test_config = pytester.parseconfig(
+ "--ibutsu", "archive", "--ibutsu-project", "test-project"
+ )
+ plugin = IbutsuPlugin.from_config(test_config)
+ assert plugin.ibutsu_source == "local"
+
+
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test for precedence when both CLI and IBUTSU_SOURCE are set
To complete coverage, please add a case where both `--ibutsu-source` and `IBUTSU_SOURCE` are set, asserting that the CLI option takes precedence over the env var. This will lock in the intended precedence behavior and protect against regressions.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (68.15%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
=======================================
Coverage 68.15% 68.15%
=======================================
Files 7 7
Lines 829 829
Branches 140 140
=======================================
Hits 565 565
Misses 235 235
Partials 29 29
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
35eb016 to
edd73c1
Compare
Summary by Sourcery
Adjust ibutsu source configuration defaults and document their behavior.
Enhancements:
Tests: