fix: align BDD tests and mock server with real API behavior#198
fix: align BDD tests and mock server with real API behavior#198
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/integration/features/steps/cli_steps.py`:
- Around line 51-56: The general exception handler in step_run_cli_command
doesn't set context.cli_stdout, causing attribute errors downstream; update the
broad except Exception handler to initialize context.cli_stdout = "" (matching
the TimeoutExpired handler) before re-raising so callers can always rely on
context.cli_stdout existing; locate the try/except in step_run_cli_command (and
the existing except subprocess.TimeoutExpired block) and add the initialization
there.
🧹 Nitpick comments (1)
tests/integration/run_tests.py (1)
27-48: Git-based external configuration detection may have edge cases.The approach comparing file mtime to git commit time is clever, but consider these scenarios:
- If
session.jsonwas modified locally but not committed,git logreturns the last commit time for that file, which could falsely indicate external configuration.- If the file is newly created and not yet tracked by git,
git logmay output nothing, causingint(result.stdout.strip())to fail on empty string.The current exception handling catches most failures gracefully by returning
False, which is safe default behavior. This is acceptable for the "Chill" review mode.💡 Alternative approach using git status
def is_session_externally_configured(test_home): """Check if session.json has been modified from the committed version.""" session_file = test_home / ".config" / "tower" / "session.json" if not session_file.exists(): return False try: # Check if file differs from committed version result = subprocess.run( ["git", "diff", "--quiet", str(session_file)], capture_output=True, ) # Non-zero exit means file has changes return result.returncode != 0 except (subprocess.CalledProcessError, FileNotFoundError): return False
| context.cli_stdout = result.stdout | ||
| context.cli_return_code = result.returncode | ||
| except subprocess.TimeoutExpired: | ||
| context.cli_output = "Command timed out" | ||
| context.cli_stdout = "" | ||
| context.cli_return_code = 124 |
There was a problem hiding this comment.
Consider initializing cli_stdout in the general exception handler.
The timeout handler sets context.cli_stdout = "", but the general exception handler (lines 57-61) re-raises without setting it. If any downstream code assumes cli_stdout exists after step_run_cli_command, this could cause an AttributeError in edge cases.
🐛 Proposed fix
except subprocess.TimeoutExpired:
context.cli_output = "Command timed out"
context.cli_stdout = ""
context.cli_return_code = 124
except Exception as e:
+ context.cli_stdout = ""
print(f"DEBUG: Exception in CLI command: {type(e).__name__}: {e}")
print(f"DEBUG: Command was: {full_command}")
print(f"DEBUG: Working directory: {os.getcwd()}")
raise🤖 Prompt for AI Agents
In `@tests/integration/features/steps/cli_steps.py` around lines 51 - 56, The
general exception handler in step_run_cli_command doesn't set
context.cli_stdout, causing attribute errors downstream; update the broad except
Exception handler to initialize context.cli_stdout = "" (matching the
TimeoutExpired handler) before re-raising so callers can always rely on
context.cli_stdout existing; locate the try/except in step_run_cli_command (and
the existing except subprocess.TimeoutExpired block) and add the initialization
there.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c6f6074 to
88183c2
Compare
We want to run the BDD integration tests against the real Tower server (from the monorepo) to catch discrepancies between the mock and real API. This PR fixes the gaps found doing that:
TOWER_URLenv var, skipping mock server startup and session fixture resetSummary by CodeRabbit