-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for setting the path to the
op
command (#1)
- Loading branch information
1 parent
4329d8d
commit 0a01a29
Showing
6 changed files
with
67 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from django.test import override_settings | ||
|
||
from django_opfield.conf import app_settings | ||
|
||
|
||
@patch.dict(os.environ, {"OP_CLI_PATH": ""}) | ||
class TestOPCliPath: | ||
@patch("shutil.which") | ||
def test_default(self, mock_which): | ||
mock_which.return_value = None | ||
|
||
with pytest.raises(ImportError): | ||
assert app_settings.OP_CLI_PATH | ||
|
||
@override_settings(DJANGO_OPFIELD={"OP_CLI_PATH": "path/to/op"}) | ||
def test_user_setting(self): | ||
assert "path/to/op" in str(app_settings.OP_CLI_PATH) | ||
|
||
@patch.dict(os.environ, {"OP_CLI_PATH": "path/to/op"}) | ||
def test_env_var(self): | ||
assert "path/to/op" in str(app_settings.OP_CLI_PATH) | ||
|
||
@patch("shutil.which") | ||
def test_shutil_which(self, mock_which): | ||
mock_which.return_value = "path/to/op" | ||
|
||
assert "path/to/op" in str(app_settings.OP_CLI_PATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters