Skip to content

Commit

Permalink
Add fixture to configure recorder DB properly
Browse files Browse the repository at this point in the history
  • Loading branch information
zeronounours committed May 22, 2023
1 parent a6a0936 commit 1197aca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def auto_enable_custom_integrations(enable_custom_integrations):
yield


# Used to create a config with necessary sections to run tests
@pytest.fixture(name="config")
def config(request):
"""Create a fixture to add config required for tests."""
with patch("homeassistant.components.recorder.ALLOW_IN_MEMORY_DB", True):
yield {"recorder": {"db_url": "sqlite:///:memory:"}} | request.param


# Used to initialize the recorder
@pytest.fixture(autouse=True)
def auto_initialize_recorder(hass):
Expand Down
1 change: 1 addition & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@
marks=pytest.mark.xfail(reason="Currently under issue #2"),
),
],
indirect=("config",),
)
async def test_setup_and_check_created_sensors(hass, config, created_sensors):
"""Test the setup and tests created sensors."""
Expand Down

0 comments on commit 1197aca

Please sign in to comment.