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
1d6ecbd1
Unverified
Commit
1d6ecbd1
authored
3 months ago
by
starkillerOG
Committed by
GitHub
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Change Reolink test switch entity ID (#134339)
parent
c8276ec3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/components/reolink/test_switch.py
+18
-17
18 additions, 17 deletions
tests/components/reolink/test_switch.py
with
18 additions
and
17 deletions
tests/components/reolink/test_switch.py
+
18
−
17
View file @
1d6ecbd1
...
...
@@ -248,16 +248,17 @@ async def test_switch(
)
->
None
:
"""
Test switch entity.
"""
reolink_connect
.
camera_name
.
return_value
=
TEST_CAM_NAME
reolink_connect
.
audio_record
.
return_value
=
True
with
patch
(
"
homeassistant.components.reolink.PLATFORMS
"
,
[
Platform
.
SWITCH
]):
assert
await
hass
.
config_entries
.
async_setup
(
config_entry
.
entry_id
)
await
hass
.
async_block_till_done
()
assert
config_entry
.
state
is
ConfigEntryState
.
LOADED
entity_id
=
f
"
{
Platform
.
SWITCH
}
.
{
TEST_CAM_NAME
}
_record
"
entity_id
=
f
"
{
Platform
.
SWITCH
}
.
{
TEST_CAM_NAME
}
_record
_audio
"
assert
hass
.
states
.
get
(
entity_id
).
state
==
STATE_ON
reolink_connect
.
recording_enable
d
.
return_value
=
False
reolink_connect
.
audio_recor
d
.
return_value
=
False
freezer
.
tick
(
DEVICE_UPDATE_INTERVAL
)
async_fire_time_changed
(
hass
)
await
hass
.
async_block_till_done
()
...
...
@@ -271,9 +272,9 @@ async def test_switch(
{
ATTR_ENTITY_ID
:
entity_id
},
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
assert_called_with
(
0
,
True
)
reolink_connect
.
set_
audio
.
assert_called_with
(
0
,
True
)
reolink_connect
.
set_
recording
.
side_effect
=
ReolinkError
(
"
Test error
"
)
reolink_connect
.
set_
audio
.
side_effect
=
ReolinkError
(
"
Test error
"
)
with
pytest
.
raises
(
HomeAssistantError
):
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
...
...
@@ -283,16 +284,16 @@ async def test_switch(
)
# test switch turn off
reolink_connect
.
set_
recording
.
reset_mock
(
side_effect
=
True
)
reolink_connect
.
set_
audio
.
reset_mock
(
side_effect
=
True
)
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
SERVICE_TURN_OFF
,
{
ATTR_ENTITY_ID
:
entity_id
},
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
assert_called_with
(
0
,
False
)
reolink_connect
.
set_
audio
.
assert_called_with
(
0
,
False
)
reolink_connect
.
set_
recording
.
side_effect
=
ReolinkError
(
"
Test error
"
)
reolink_connect
.
set_
audio
.
side_effect
=
ReolinkError
(
"
Test error
"
)
with
pytest
.
raises
(
HomeAssistantError
):
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
...
...
@@ -301,7 +302,7 @@ async def test_switch(
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
reset_mock
(
side_effect
=
True
)
reolink_connect
.
set_
audio
.
reset_mock
(
side_effect
=
True
)
reolink_connect
.
camera_online
.
return_value
=
False
freezer
.
tick
(
DEVICE_UPDATE_INTERVAL
)
...
...
@@ -321,17 +322,17 @@ async def test_host_switch(
)
->
None
:
"""
Test host switch entity.
"""
reolink_connect
.
camera_name
.
return_value
=
TEST_CAM_NAME
reolink_connect
.
recording
_enabled
.
return_value
=
True
reolink_connect
.
email
_enabled
.
return_value
=
True
with
patch
(
"
homeassistant.components.reolink.PLATFORMS
"
,
[
Platform
.
SWITCH
]):
assert
await
hass
.
config_entries
.
async_setup
(
config_entry
.
entry_id
)
await
hass
.
async_block_till_done
()
assert
config_entry
.
state
is
ConfigEntryState
.
LOADED
entity_id
=
f
"
{
Platform
.
SWITCH
}
.
{
TEST_NVR_NAME
}
_
record
"
entity_id
=
f
"
{
Platform
.
SWITCH
}
.
{
TEST_NVR_NAME
}
_
email_on_event
"
assert
hass
.
states
.
get
(
entity_id
).
state
==
STATE_ON
reolink_connect
.
recording
_enabled
.
return_value
=
False
reolink_connect
.
email
_enabled
.
return_value
=
False
freezer
.
tick
(
DEVICE_UPDATE_INTERVAL
)
async_fire_time_changed
(
hass
)
await
hass
.
async_block_till_done
()
...
...
@@ -345,9 +346,9 @@ async def test_host_switch(
{
ATTR_ENTITY_ID
:
entity_id
},
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
assert_called_with
(
None
,
True
)
reolink_connect
.
set_
email
.
assert_called_with
(
None
,
True
)
reolink_connect
.
set_
recording
.
side_effect
=
ReolinkError
(
"
Test error
"
)
reolink_connect
.
set_
email
.
side_effect
=
ReolinkError
(
"
Test error
"
)
with
pytest
.
raises
(
HomeAssistantError
):
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
...
...
@@ -357,16 +358,16 @@ async def test_host_switch(
)
# test switch turn off
reolink_connect
.
set_
recording
.
reset_mock
(
side_effect
=
True
)
reolink_connect
.
set_
email
.
reset_mock
(
side_effect
=
True
)
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
SERVICE_TURN_OFF
,
{
ATTR_ENTITY_ID
:
entity_id
},
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
assert_called_with
(
None
,
False
)
reolink_connect
.
set_
email
.
assert_called_with
(
None
,
False
)
reolink_connect
.
set_
recording
.
side_effect
=
ReolinkError
(
"
Test error
"
)
reolink_connect
.
set_
email
.
side_effect
=
ReolinkError
(
"
Test error
"
)
with
pytest
.
raises
(
HomeAssistantError
):
await
hass
.
services
.
async_call
(
SWITCH_DOMAIN
,
...
...
@@ -375,7 +376,7 @@ async def test_host_switch(
blocking
=
True
,
)
reolink_connect
.
set_
recording
.
reset_mock
(
side_effect
=
True
)
reolink_connect
.
set_
email
.
reset_mock
(
side_effect
=
True
)
async
def
test_chime_switch
(
...
...
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