def test_jobmgr_get_jobs(self, mock_job, mock_api, mock_creds, mock_cfg):
        """Test get_jobs"""

        mgr = JobManager(mock_creds, cfg=mock_cfg)

        resp = mock.create_autospec(Response)
        resp.success = False
        resp.result = RestCallException(None, "test", None)
        mgr._client.list_jobs.return_value = resp

        with self.assertRaises(RestCallException):
            mgr.get_jobs()
        mgr._client.list_jobs.assert_called_with(0, 10)

        resp.success = True
        resp.result = {'totalCount':10, 'jobs':[]}
        jobs = mgr.get_jobs(10, "5", 5)
        mgr._client.list_jobs.assert_called_with(10, 5, name='5')
        self.assertEqual(jobs, [])
        self.assertEqual(len(mgr), 10)

        resp.result = {'totalCount':10, 'jobs':[{'id':'1', 'name':'2'}]}
        with self.assertRaises(RestCallException):
            mgr.get_jobs(name="test")

        resp.result = {'totalCount':10,
                       'jobs':[{'id':'1',
                                'name':'2',
                                'type':'3',
                                'other':'4'}]}

        jobs = mgr.get_jobs(index="10")
        mock_job.assert_called_with(mgr._client, '1', '2', '3', other='4')
        self.assertEqual(len(jobs), 1)
    def test_jobmgr_get_jobs(self, mock_job, mock_api, mock_creds, mock_cfg):
        """Test get_jobs"""

        mgr = JobManager(mock_creds, cfg=mock_cfg)

        resp = mock.create_autospec(Response)
        resp.success = False
        resp.result = RestCallException(None, "test", None)
        mgr._client.list_jobs.return_value = resp

        with self.assertRaises(RestCallException):
            mgr.get_jobs()
        mgr._client.list_jobs.assert_called_with(0, 10)

        resp.success = True
        resp.result = {'totalCount': 10, 'jobs': []}
        jobs = mgr.get_jobs(10, "5", 5)
        mgr._client.list_jobs.assert_called_with(10, 5, name='5')
        self.assertEqual(jobs, [])
        self.assertEqual(len(mgr), 10)

        resp.result = {'totalCount': 10, 'jobs': [{'id': '1', 'name': '2'}]}
        with self.assertRaises(RestCallException):
            mgr.get_jobs(name="test")

        resp.result = {
            'totalCount': 10,
            'jobs': [{
                'id': '1',
                'name': '2',
                'type': '3',
                'other': '4'
            }]
        }

        jobs = mgr.get_jobs(index="10")
        mock_job.assert_called_with(mgr._client, '1', '2', '3', other='4')
        self.assertEqual(len(jobs), 1)