def test_applications_dont_load_without_params(mock_config): """Verify that you can list parameters.""" with patch("axis.vapix.session_request", return_value="key=value") as mock_request: vapix = Vapix(mock_config) vapix.initialize_param_cgi(preload_data=False) vapix.initialize_applications() mock_request.assert_not_called
def test_initialize_applications_not_running(mock_config): """Verify you can list and retrieve descriptions of applications.""" with patch( "axis.vapix.session_request", side_effect=[ response_param_cgi, json.dumps(light_control_response), applications_response.replace( APPLICATION_STATE_RUNNING, APPLICATION_STATE_STOPPED ), ], ) as mock_request: vapix = Vapix(mock_config) vapix.initialize_param_cgi() vapix.initialize_applications() assert vapix.fence_guard is None assert vapix.motion_guard is None assert vapix.vmd4 is None
def test_initialize_applications(mock_config): """Verify you can list and retrieve descriptions of applications.""" with patch( "axis.vapix.session_request", side_effect=[ response_param_cgi, json.dumps(light_control_response), applications_response, json.dumps(fence_guard_response), json.dumps(loitering_guard_response), json.dumps(motion_guard_response), json.dumps(vmd4_response), ], ) as mock_request: vapix = Vapix(mock_config) vapix.initialize_param_cgi() vapix.initialize_applications() assert vapix.fence_guard assert vapix.loitering_guard assert vapix.motion_guard assert vapix.vmd4 mock_request.assert_has_calls( [ call("mock_post", "mock_url/axis-cgi/applications/list.cgi"), call( "mock_post", "mock_url/local/fenceguard/control.cgi", json={ "method": "getConfiguration", "apiVersion": "1.3", "context": "Axis library", }, ), call( "mock_post", "mock_url/local/loiteringguard/control.cgi", json={ "method": "getConfiguration", "apiVersion": "1.3", "context": "Axis library", }, ), call( "mock_post", "mock_url/local/motionguard/control.cgi", json={ "method": "getConfiguration", "apiVersion": "1.3", "context": "Axis library", }, ), call( "mock_post", "mock_url/local/vmd/control.cgi", json={ "method": "getConfiguration", "apiVersion": "1.2", "context": "Axis library", }, ), ] ) assert len(vapix.applications.values()) == 7 assert len(vapix.fence_guard.values()) == 1 assert "Camera1Profile1" in vapix.fence_guard assert len(vapix.loitering_guard.values()) == 1 assert "Camera1Profile1" in vapix.loitering_guard assert len(vapix.motion_guard.values()) == 1 assert "Camera1Profile1" in vapix.motion_guard assert len(vapix.vmd4.values()) == 1 assert "Camera1Profile1" in vapix.vmd4