Skip to content

Commit

Permalink
Add another get_homescreen() call after 2fa verification
Browse files Browse the repository at this point in the history
Follow up to #941 as discussed in #917 to fix missing owls/lotus.
  • Loading branch information
mback2k committed Jun 9, 2024
1 parent 3057783 commit 69e0165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 69e0165

Please sign in to comment.