The cli/tests/test_check_env.py tests are updated to correctly test the behaviour of pixl check-env.
Testing
Should update cli/tests/test_check_env.py
Suggested test cases:
check_env(error=True) should pass without errors
check_env(error=True) should return an error when a NONEXISTENT_VARIABLE envvar is set in the sample file
check_env(error=False) should not return an error when a NONEXISTENT_VARIABLE envvar is set in the sample file (might be overkill)
Documentation
No response
Dependencies
No response
Details and Comments
The tests in test_check_env.py are currently passing because of the wrong reasons:
test_check_env() passes because it's calling check_env with default options, so error = False and so will never return a non-zero exit code
test_check_env_fails() passes because it's calling runner.invoke() in a faulty way. It also has error=False so the non-zero exit code doesn't actually come from check_env
To reproduce, modifying test_check_env() to the following still passes (but shouldn't!):
def test_check_env(tmp_path):
"""
Test that the check_env command runs without error.
- check_env works
- current test env file matches the sample env file
"""
tmp_sample_env_file = tmp_path / ".env.sample"
tmp_sample_env_file.write_text("NONEXISTENT_VARIABLE=")
runner = CliRunner()
result = runner.invoke(check_env, ["--sample-env-file", tmp_sample_env_file])
assert result.exit_code == 0
Definition of Done / Acceptance Criteria
The
cli/tests/test_check_env.py
tests are updated to correctly test the behaviour ofpixl check-env
.Testing
Should update
cli/tests/test_check_env.py
Suggested test cases:
check_env(error=True)
should pass without errorscheck_env(error=True)
should return an error when aNONEXISTENT_VARIABLE
envvar is set in the sample filecheck_env(error=False)
should not return an error when aNONEXISTENT_VARIABLE
envvar is set in the sample file (might be overkill)Documentation
No response
Dependencies
No response
Details and Comments
The tests in
test_check_env.py
are currently passing because of the wrong reasons:test_check_env()
passes because it's callingcheck_env
with default options, soerror = False
and so will never return a non-zero exit codetest_check_env_fails()
passes because it's callingrunner.invoke()
in a faulty way. It also haserror=False
so the non-zero exit code doesn't actually come fromcheck_env
To reproduce, modifying
test_check_env()
to the following still passes (but shouldn't!):