asl-node-auth-check: Tighten up key failures#195
Conversation
Add 100% coverage
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tests/test_asl_node_auth_check/test_asl_node_auth_check_main.py (2)
362-426: Consider using underscore prefix for unused unpacked variables.Multiple tests unpack tuples but don't use all values. While this works, static analysis tools flag these. Using
_prefix for unused variables is a Python convention that silences these warnings and makes intent clearer.Example fix:
- host, perceived, state = _module.find_iax_registration("12345") + _host, _perceived, state = _module.find_iax_registration("12345") assert state == "Request Sent"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_asl_node_auth_check/test_asl_node_auth_check_main.py` around lines 362 - 426, Several tests unpack the triple returned by _module.find_iax_registration but only assert a subset of the values; update those tests to use underscore-prefixed names for unused unpacked variables (e.g., change "host, perceived, state = _module.find_iax_registration(...)" to "_host, _perceived, state = _module.find_iax_registration(...)" or similar) in the following test functions: test_iax_insufficient_lines, test_iax_insufficient_columns, test_iax_subprocess_error (and any other tests in this file that ignore some return values) so static analyzers stop flagging unused variables while keeping assertions against the used names.
198-206: Remove extraneousfprefix from strings without placeholders.Lines 198-206 contain f-strings that have no interpolation placeholders. These should be regular strings.
Proposed fix
- main_content = f""" + main_content = """ [12345] (node-main) `#include` subdir/sub.conf """ - sub_content = """ + sub_content = """ [54321] (node-main) """🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_asl_node_auth_check/test_asl_node_auth_check_main.py` around lines 198 - 206, The two string assignments main_content and sub_content use f-strings but contain no interpolation; change their declarations from f"""...""" to regular triple-quoted strings ("""...""") so main_content and sub_content are plain strings without the unnecessary f-prefix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_asl_node_auth_check/test_asl_node_auth_check_main.py`:
- Around line 41-48: The run() helper creates buf = io.StringIO() but never
redirects stdout into it, so printed output from _module.entrypoint() is lost;
update run() to redirect sys.stdout to buf while calling _module.entrypoint()
(e.g., use contextlib.redirect_stdout(buf) or patch sys.stdout to buf inside the
with patch.dict(sys.modules) block) so that buf.getvalue() returns captured
output, preserving the existing SystemExit handling.
- Around line 79-90: The test test_main_valid_user is patching pwd.getpwnam but
the code calls require_root_or_asterisk (invoked by entrypoint) which uses
pwd.getpwuid(uid).pw_name, so update the test to patch pwd.getpwuid instead of
pwd.getpwnam; specifically, in test_main_valid_user replace the patch target
"pwd.getpwnam" with "pwd.getpwuid" and return a MagicMock with pw_uid, pw_gid,
and pw_name as before so require_root_or_asterisk sees the mocked username for
the given uid.
---
Nitpick comments:
In `@tests/test_asl_node_auth_check/test_asl_node_auth_check_main.py`:
- Around line 362-426: Several tests unpack the triple returned by
_module.find_iax_registration but only assert a subset of the values; update
those tests to use underscore-prefixed names for unused unpacked variables
(e.g., change "host, perceived, state = _module.find_iax_registration(...)" to
"_host, _perceived, state = _module.find_iax_registration(...)" or similar) in
the following test functions: test_iax_insufficient_lines,
test_iax_insufficient_columns, test_iax_subprocess_error (and any other tests in
this file that ignore some return values) so static analyzers stop flagging
unused variables while keeping assertions against the used names.
- Around line 198-206: The two string assignments main_content and sub_content
use f-strings but contain no interpolation; change their declarations from
f"""...""" to regular triple-quoted strings ("""...""") so main_content and
sub_content are plain strings without the unnecessary f-prefix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bb3d48ca-82e1-41a6-94b1-28647c7b49d1
📒 Files selected for processing (4)
bin/asl-node-auth-checktests/test_asl_node_auth_check/test_asl_node_auth_check_http.pytests/test_asl_node_auth_check/test_asl_node_auth_check_main.pytests/test_asl_node_auth_check/test_asl_node_auth_check_reachability.py
Add 100% coverage
Summary by CodeRabbit
Bug Fixes
Tests