-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct url path checking and path append
- Loading branch information
Showing
11 changed files
with
162 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,47 @@ | ||
import pytest | ||
|
||
from unittest.mock import MagicMock, patch | ||
from unittest.mock import patch | ||
|
||
from .config import Config, _get_api_key, _get_url | ||
|
||
|
||
class TestGetApiKey: | ||
@patch.dict("os.environ", {"CONNECT_API_KEY": "foobar"}) | ||
def test_get_api_key(self): | ||
api_key = _get_api_key() | ||
assert api_key == "foobar" | ||
@patch.dict("os.environ", {"CONNECT_API_KEY": "foobar"}) | ||
def test_get_api_key(): | ||
api_key = _get_api_key() | ||
assert api_key == "foobar" | ||
|
||
@patch.dict("os.environ", {"CONNECT_API_KEY": ""}) | ||
def test_get_api_key_empty(self): | ||
with pytest.raises(ValueError): | ||
_get_api_key() | ||
|
||
def test_get_api_key_miss(self): | ||
with pytest.raises(ValueError): | ||
_get_api_key() | ||
@patch.dict("os.environ", {"CONNECT_API_KEY": ""}) | ||
def test_get_api_key_empty(): | ||
with pytest.raises(ValueError): | ||
_get_api_key() | ||
|
||
|
||
class TestGetUrl: | ||
@patch.dict("os.environ", {"CONNECT_SERVER": "http://foo.bar"}) | ||
def test_get_endpoint(self): | ||
url = _get_url() | ||
assert url == "http://foo.bar" | ||
def test_get_api_key_miss(): | ||
with pytest.raises(ValueError): | ||
_get_api_key() | ||
|
||
@patch.dict("os.environ", {"CONNECT_SERVER": ""}) | ||
def test_get_endpoint_empty(self): | ||
with pytest.raises(ValueError): | ||
_get_url() | ||
|
||
def test_get_endpoint_miss(self): | ||
with pytest.raises(ValueError): | ||
_get_url() | ||
@patch.dict("os.environ", {"CONNECT_SERVER": "http://foo.bar"}) | ||
def test_get_url(): | ||
url = _get_url() | ||
assert url == "http://foo.bar" | ||
|
||
|
||
class TestConfig: | ||
@patch("posit.connect.config.Url") | ||
def test_init(self, Url: MagicMock): | ||
api_key = "foobar" | ||
url = "http://foo.bar" | ||
config = Config(api_key=api_key, url=url) | ||
assert config.api_key == api_key | ||
assert config.url == Url.return_value | ||
Url.assert_called_with(url) | ||
@patch.dict("os.environ", {"CONNECT_SERVER": ""}) | ||
def test_get_url_empty(): | ||
with pytest.raises(ValueError): | ||
_get_url() | ||
|
||
|
||
def test_get_url_miss(): | ||
with pytest.raises(ValueError): | ||
_get_url() | ||
|
||
|
||
def test_init(): | ||
api_key = "foobar" | ||
url = "http://foo.bar" | ||
config = Config(api_key=api_key, url=url) | ||
assert config.api_key == api_key | ||
assert config.url == url |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.