Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change to RuntimeError if op CLI not found #14

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/

## [Unreleased]

### Changed

- Changed exception raised if `op` CLI not found to `RuntimeError`.

### Fixed

- Removed the passing in of just the `OP_SERVICE_ACCOUNT_TOKEN` variable to the `subprocess.run` call to `op`. This was clobbering the environment and causing configuration issues with the `op` CLI. First reported in [#12](https://github.com/westerveltco/django-opfield/issues/12) by [@joshuadavidthomas](https://github.com/joshuadavidthomas).
Expand Down
2 changes: 1 addition & 1 deletion src/django_opfield/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_op_cli_path(self) -> Path:
path = shutil.which("op")

if not path:
raise ImportError("Could not find the 'op' CLI command")
raise RuntimeError("Could not find the 'op' CLI command")

return Path(path).resolve()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setup(self):
def test_default(self, mock_which):
mock_which.return_value = None

with pytest.raises(ImportError) as exc_info:
with pytest.raises(RuntimeError) as exc_info:
assert app_settings.get_op_cli_path()

assert "Could not find the 'op' CLI command" in str(exc_info.value)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_get_secret_command_not_available(mock_which, db):

model = OPFieldModel(op_uri="op://vault/item/field")

with pytest.raises(ImportError) as excinfo:
with pytest.raises(RuntimeError) as excinfo:
_ = model.op_uri_secret

assert "Could not find the 'op' CLI command" in str(excinfo.value)
Expand Down