Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add another get_homescreen() call after 2fa verification #945

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions blinkpy/blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ async def setup_prompt_2fa(self):
async def setup_post_verify(self):
"""Initialize blink system after verification."""
try:
if not self.homescreen:
await self.get_homescreen()
await self.setup_networks()
networks = self.setup_network_ids()
cameras = await self.setup_camera_list()
Expand Down
8 changes: 6 additions & 2 deletions tests/test_blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ async def test_setup_prompt_2fa(self, mock_key):
self.assertTrue(self.blink.key_required)

@mock.patch("blinkpy.blinkpy.Blink.setup_camera_list")
@mock.patch("blinkpy.api.request_homescreen")
@mock.patch("blinkpy.api.request_networks")
@mock.patch("blinkpy.blinkpy.Blink.setup_owls")
@mock.patch("blinkpy.blinkpy.Blink.setup_lotus")
@mock.patch("blinkpy.blinkpy.BlinkSyncModule.start")
async def test_setup_post_verify(
self, mock_sync, mock_lotus, mock_owl, mock_networks, mock_camera
self, mock_sync, mock_lotus, mock_owl, mock_networks, mock_home, mock_camera
):
"""Test setup after verification."""
self.blink.available = False
Expand All @@ -214,16 +215,19 @@ async def test_setup_post_verify(
mock_networks.return_value = {
"summary": {"foo": {"onboarded": True, "name": "bar"}}
}
mock_home.return_value = {}
mock_camera.return_value = []
self.assertTrue(await self.blink.setup_post_verify())
self.assertTrue(self.blink.available)
self.assertFalse(self.blink.key_required)

@mock.patch("blinkpy.api.request_homescreen")
@mock.patch("blinkpy.api.request_networks")
async def test_setup_post_verify_failure(self, mock_networks):
async def test_setup_post_verify_failure(self, mock_networks, mock_home):
"""Test failed setup after verification."""
self.blink.available = False
mock_networks.return_value = {}
mock_home.return_value = {}
self.assertFalse(await self.blink.setup_post_verify())
self.assertFalse(self.blink.available)

Expand Down
Loading