#NEWLINE# @ mock . patch ( 'uvcclient.nvr.UVCRemote' ) #NEWLINE# @ mock . patch . object ( uvc , 'UnifiVideoCamera' ) #NEWLINE# def test_setup_full_config( self , mock_uvc , mock_remote ) : #NEWLINE# #INDENT# '"Test the setup with full configuration.' #NEWLINE# config = { #NEWLINE# #INDENT# 'nvr' : 'foo' , #NEWLINE# 'port' : 123 , #NEWLINE# 'key' : 'secret' , #NEWLINE# #UNINDENT# } #NEWLINE# fake_cameras = [ { #NEWLINE# #INDENT# 'uuid' : 'one' , #NEWLINE# 'name' : 'Front' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'uuid' : 'two' , #NEWLINE# 'name' : 'Back' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'uuid' : 'three' , #NEWLINE# 'name' : 'Old AirCam' , #NEWLINE# #UNINDENT# } ] #NEWLINE# def fake_get_camera( uuid ) : #NEWLINE# #INDENT# '"Create a fake camera.' #NEWLINE# if ( uuid == 'three' ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'model' : 'airCam' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'model' : 'UVC' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# hass = mock . MagicMock ( ) #NEWLINE# add_devices = mock . MagicMock ( ) #NEWLINE# mock_remote . return_value . index . return_value = fake_cameras #NEWLINE# mock_remote . return_value . get_camera . side_effect = fake_get_camera #NEWLINE# self . assertTrue ( uvc . setup_platform ( hass , config , add_devices ) ) #NEWLINE# mock_remote . assert_called_once_with ( 'foo' , 123 , 'secret' ) #NEWLINE# add_devices . assert_called_once_with ( [ mock_uvc . return_value , mock_uvc . return_value ] ) #NEWLINE# mock_uvc . assert_has_calls ( [ mock . call ( mock_remote . return_value , 'one' , 'Front' ) , mock . call ( mock_remote . return_value , 'two' , 'Back' ) ] )