-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix #75 and abstract functions * Add tests * Add tests to .travis.yml
- Loading branch information
1 parent
d1b0f2e
commit 9513a8a
Showing
5 changed files
with
92 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest==4.0.2 | ||
requests==2.21.0 |
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,38 @@ | ||
import os | ||
import pytest | ||
|
||
from haaska import HomeAssistant, Configuration | ||
|
||
@pytest.fixture | ||
def configuration(): | ||
return Configuration(opts_dict={ | ||
"url": "http://localhost:8123", | ||
"bearer_token": "", | ||
"debug": False, | ||
"ssl_verify": True, | ||
"ssl_client": [] | ||
}) | ||
|
||
@pytest.fixture | ||
def home_assistant(configuration): | ||
return HomeAssistant(configuration) | ||
|
||
def test_ha_build_url(home_assistant): | ||
url = home_assistant.build_url("test") | ||
assert url == "http://localhost:8123/api/test" | ||
|
||
def test_get_user_agent(home_assistant): | ||
os.environ["AWS_DEFAULT_REGION"] = "test" | ||
user_agent = home_assistant.get_user_agent() | ||
assert user_agent.startswith("Home Assistant Alexa Smart Home Skill - test - python-requests/") | ||
|
||
def test_config_get(configuration): | ||
assert configuration.get(["debug"]) == False | ||
assert configuration.get(["test"]) == None | ||
assert configuration.get(["test"], default="default") == "default" | ||
|
||
def test_config_get_url(configuration): | ||
expected = "http://hass.example.com:8123" | ||
assert configuration.get_url("http://hass.example.com:8123/") == expected | ||
assert configuration.get_url("http://hass.example.com:8123/api") == expected | ||
assert configuration.get_url("http://hass.example.com:8123/api/") == expected |