def test_vxuserapi_one_analysis(): request = mock.Mock(return_value={"id": 42}) with mock.patch("vxcube_api.raw_api.VxCubeApiRequest.request", new=request): api = VxCubeApi(base_url="http://test", version=2.0) analysis = api.analyses(analysis_id=42) assert isinstance(analysis, Analysis) assert analysis.id == 42 assert analysis._raw_api is api._raw_api request.assert_called_with(method="get", url="http://test/api-2.0/analyses/42", params={}, headers={})
def test_vxuserapi_many_analyses(): kwargs = dict(count=4, offset=2, format_group_name=None) request = mock.Mock(return_value=[{"id": 23}, {"id": 42}]) with mock.patch("vxcube_api.raw_api.VxCubeApiRequest.request", new=request): api = VxCubeApi(base_url="http://test", version=2.0) analyses = api.analyses(**kwargs) assert isinstance(analyses, list) assert len(analyses) == 2 assert analyses[0].id == 23 assert analyses[0]._raw_api is api._raw_api assert analyses[1].id == 42 assert analyses[1]._raw_api is api._raw_api request.assert_called_with(method="get", url="http://test/api-2.0/analyses", params={}, headers={}, json={ "count": 4, "offset": 2 })