Skip to content

Commit

Permalink
Merge pull request #17 from agittins/dev
Browse files Browse the repository at this point in the history
(wip): Get tests working
  • Loading branch information
agittins authored Aug 24, 2023
2 parents 04b1569 + e39c8b2 commit 8f10784
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 101 deletions.
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r requirements.txt
pytest-asyncio
pytest-homeassistant-custom-component
#==0.13.50
pre-commit
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Create a virtual environment
python3 -m venv venv
Expand Down
28 changes: 15 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ def skip_notifications_fixture():
# async_get_data to return None. To have the call
# return a value, we would add the `return_value=<VALUE_TO_RETURN>`
# parameter to the patch call.
@pytest.fixture(name="bypass_get_data")
def bypass_get_data_fixture():
"""Skip calls to get data from API."""
with patch("custom_components.bermuda.BermudaApiClient.async_get_data"):
yield
# AJG - we aren't using the API, and probably won't.
# @pytest.fixture(name="bypass_get_data")
# def bypass_get_data_fixture():
# """Skip calls to get data from API."""
# with patch("custom_components.bermuda.BermudaApiClient.async_get_data"):
# yield


# In this fixture, we are forcing calls to async_get_data to raise
# an Exception. This is useful
# for exception handling.
@pytest.fixture(name="error_on_get_data")
def error_get_data_fixture():
"""Simulate error when retrieving data from API."""
with patch(
"custom_components.bermuda.BermudaApiClient.async_get_data",
side_effect=Exception,
):
yield
# AJG - No API for us.
# @pytest.fixture(name="error_on_get_data")
# def error_get_data_fixture():
# """Simulate error when retrieving data from API."""
# with patch(
# "custom_components.bermuda.BermudaApiClient.async_get_data",
# side_effect=Exception,
# ):
# yield
87 changes: 0 additions & 87 deletions tests/test_api.py

This file was deleted.

0 comments on commit 8f10784

Please sign in to comment.