-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from NabuCasa/dev
0.29
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from setuptools import setup | ||
|
||
VERSION = "0.28" | ||
VERSION = "0.29" | ||
|
||
setup( | ||
name="hass-nabucasa", | ||
|
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,39 @@ | ||
"""Tests for ThingTalk.""" | ||
import pytest | ||
|
||
import aiohttp | ||
|
||
from hass_nabucasa import thingtalk | ||
|
||
API_URL = "https://example.com" | ||
CONVERT_URL = f"{API_URL}/convert" | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def set_api_url(cloud_mock): | ||
"""Set TT API url.""" | ||
cloud_mock.thingtalk_url = API_URL | ||
|
||
|
||
async def test_async_convert_ok(aioclient_mock, cloud_mock): | ||
"""Test async convert.""" | ||
aioclient_mock.post(CONVERT_URL, json={"hello": "yo"}) | ||
assert await thingtalk.async_convert(cloud_mock, "Hello") == {"hello": "yo"} | ||
|
||
|
||
async def test_async_convert_fail(aioclient_mock, cloud_mock): | ||
"""Test async convert.""" | ||
aioclient_mock.post(CONVERT_URL, status=400, json={"error": "Convert Error!"}) | ||
with pytest.raises(thingtalk.ThingTalkConversionError) as excinfo: | ||
await thingtalk.async_convert(cloud_mock, "Hello") | ||
|
||
assert str(excinfo.value) == "Convert Error!" | ||
|
||
|
||
async def test_async_convert_invalid(aioclient_mock, cloud_mock): | ||
"""Test async convert.""" | ||
aioclient_mock.post(CONVERT_URL, status=500, text="") | ||
with pytest.raises(aiohttp.ClientResponseError) as excinfo: | ||
await thingtalk.async_convert(cloud_mock, "Hello") | ||
|
||
assert excinfo.value.status == 500 |