Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
0be68dcd
Unverified
Commit
0be68dcd
authored
8 months ago
by
Marc Mueller
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix deconz conftest typing (#122173)
parent
c92d9dcb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/components/deconz/conftest.py
+25
-14
25 additions, 14 deletions
tests/components/deconz/conftest.py
with
25 additions
and
14 deletions
tests/components/deconz/conftest.py
+
25
−
14
View file @
0be68dcd
...
...
@@ -2,16 +2,16 @@
from
__future__
import
annotations
from
collections.abc
import
Callable
,
Generator
from
collections.abc
import
Callable
,
Coroutine
,
Generator
from
types
import
MappingProxyType
from
typing
import
Any
from
typing
import
Any
,
Protocol
from
unittest.mock
import
patch
from
pydeconz.websocket
import
Signal
import
pytest
from
homeassistant.components.deconz.const
import
DOMAIN
as
DECONZ_DOMAIN
from
homeassistant.config_entries
import
SOURCE_USER
,
ConfigEntry
from
homeassistant.config_entries
import
SOURCE_USER
from
homeassistant.const
import
CONF_API_KEY
,
CONF_HOST
,
CONF_PORT
,
CONTENT_TYPE_JSON
from
homeassistant.core
import
HomeAssistant
...
...
@@ -19,10 +19,18 @@ from tests.common import MockConfigEntry
from
tests.components.light.conftest
import
mock_light_profiles
# noqa: F401
from
tests.test_util.aiohttp
import
AiohttpClientMocker
type
ConfigEntryFactoryType
=
Callable
[[
ConfigEntry
|
None
],
ConfigEntry
]
type
WebsocketDataType
=
Callable
[[
dict
[
str
,
Any
]],
None
]
type
WebsocketStateType
=
Callable
[[
str
],
None
]
type
_WebsocketMock
=
Generator
[
Any
,
Any
,
Callable
[[
dict
[
str
,
Any
]
|
None
,
str
],
None
]]
type
ConfigEntryFactoryType
=
Callable
[
[
MockConfigEntry
],
Coroutine
[
Any
,
Any
,
MockConfigEntry
]
]
type
WebsocketDataType
=
Callable
[[
dict
[
str
,
Any
]],
Coroutine
[
Any
,
Any
,
None
]]
type
WebsocketStateType
=
Callable
[[
str
],
Coroutine
[
Any
,
Any
,
None
]]
class
_WebsocketMock
(
Protocol
):
async
def
__call__
(
self
,
data
:
dict
[
str
,
Any
]
|
None
=
None
,
state
:
str
=
""
)
->
None
:
...
# Config entry fixtures
...
...
@@ -37,7 +45,7 @@ def fixture_config_entry(
config_entry_data
:
MappingProxyType
[
str
,
Any
],
config_entry_options
:
MappingProxyType
[
str
,
Any
],
config_entry_source
:
str
,
)
->
ConfigEntry
:
)
->
Mock
ConfigEntry
:
"""
Define a config entry fixture.
"""
return
MockConfigEntry
(
domain
=
DECONZ_DOMAIN
,
...
...
@@ -194,12 +202,14 @@ def fixture_sensor_1_data() -> dict[str, Any]:
@pytest.fixture
(
name
=
"
config_entry_factory
"
)
async
def
fixture_config_entry_factory
(
hass
:
HomeAssistant
,
config_entry
:
ConfigEntry
,
mock_requests
:
Callable
[[
str
,
str
],
None
],
config_entry
:
Mock
ConfigEntry
,
mock_requests
:
Callable
[[
str
],
None
],
)
->
ConfigEntryFactoryType
:
"""
Fixture factory that can set up UniFi network integration.
"""
async
def
__mock_setup_config_entry
(
entry
=
config_entry
)
->
ConfigEntry
:
async
def
__mock_setup_config_entry
(
entry
:
MockConfigEntry
=
config_entry
,
)
->
MockConfigEntry
:
entry
.
add_to_hass
(
hass
)
mock_requests
(
entry
.
data
[
CONF_HOST
])
await
hass
.
config_entries
.
async_setup
(
entry
.
entry_id
)
...
...
@@ -211,8 +221,9 @@ async def fixture_config_entry_factory(
@pytest.fixture
(
name
=
"
config_entry_setup
"
)
async
def
fixture_config_entry_setup
(
hass
:
HomeAssistant
,
config_entry_factory
:
Callable
[[],
ConfigEntry
]
)
->
ConfigEntry
:
hass
:
HomeAssistant
,
config_entry_factory
:
Callable
[[],
Coroutine
[
Any
,
Any
,
MockConfigEntry
]],
)
->
MockConfigEntry
:
"""
Fixture providing a set up instance of deCONZ integration.
"""
return
await
config_entry_factory
()
...
...
@@ -221,7 +232,7 @@ async def fixture_config_entry_setup(
@pytest.fixture
(
autouse
=
True
,
name
=
"
_mock_websocket
"
)
def
fixture_websocket
()
->
_WebsocketMock
:
def
fixture_websocket
()
->
Generator
[
_WebsocketMock
]
:
"""
No real websocket allowed.
"""
with
patch
(
"
pydeconz.gateway.WSClient
"
)
as
mock
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment