def test_fetch_tasks_all_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos',
                             host='host1',
                             id='task1',
                             staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/docker',
                             host='host2',
                             id='task2',
                             staged_at='2014-12-10T11:23:55.001Z'),
         models.MarathonTask(app_id='/chronos',
                             host='host2',
                             id='task2',
                             staged_at='2014-12-10T11:43:55.001Z')
     ]
     results = marathon_client._fetch_tasks(self.cli, None)
     self.assertEqual(
         results, {
             'chronos': [
                 models.MarathonTask(app_id='/chronos',
                                     host='host2',
                                     id='task2',
                                     staged_at='2014-12-10T11:43:55.001Z'),
                 models.MarathonTask(app_id='/chronos',
                                     host='host1',
                                     id='task1',
                                     staged_at='2014-12-10T11:44:55.001Z')
             ],
             'docker': [
                 models.MarathonTask(app_id='/docker',
                                     host='host2',
                                     id='task2',
                                     staged_at='2014-12-10T11:23:55.001Z')
             ]
         })
 def test_fetch_tasks_error(self):
     response = mock.Mock()
     response.json.return_value = {'message': 'Not found'}
     response.status_code = 404
     self.cli.list_tasks.side_effect = exceptions.MarathonHttpError(
         response)
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'), {})
 def test_fetch_tasks_some_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', host='host1', id='task1', staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/chronos', host='host2', id='task2', staged_at='2014-12-10T11:43:55.001Z')]
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'),
                      {'chronos': [models.MarathonTask(app_id='/chronos', host='host2', id='task2',
                                                       staged_at='2014-12-10T11:43:55.001Z'),
                                   models.MarathonTask(app_id='/chronos', host='host1', id='task1',
                                                       staged_at='2014-12-10T11:44:55.001Z')]})
 def test_fetch_tasks_some_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', host='host1', id='task1', staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/chronos', host='host2', id='task2', staged_at='2014-12-10T11:43:55.001Z')]
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'),
                      {'chronos': [models.MarathonTask(app_id='/chronos', host='host2', id='task2',
                                                       staged_at='2014-12-10T11:43:55.001Z'),
                                   models.MarathonTask(app_id='/chronos', host='host1', id='task1',
                                                       staged_at='2014-12-10T11:44:55.001Z')]})
 def test_fetch_tasks_all_tasks(self):
     self.cli.list_tasks.return_value = [
         models.MarathonTask(app_id='/chronos', host='host1', id='task1', staged_at='2014-12-10T11:44:55.001Z'),
         models.MarathonTask(app_id='/docker', host='host2', id='task2', staged_at='2014-12-10T11:23:55.001Z'),
         models.MarathonTask(app_id='/chronos', host='host2', id='task2', staged_at='2014-12-10T11:43:55.001Z')]
     results = marathon_client._fetch_tasks(self.cli, None)
     self.assertEqual(results,
                      {'chronos': [models.MarathonTask(app_id='/chronos', host='host2', id='task2',
                                                       staged_at='2014-12-10T11:43:55.001Z'),
                                   models.MarathonTask(app_id='/chronos', host='host1', id='task1',
                                                       staged_at='2014-12-10T11:44:55.001Z')],
                       'docker': [models.MarathonTask(app_id='/docker', host='host2', id='task2',
                                                      staged_at='2014-12-10T11:23:55.001Z')]})
 def test_fetch_tasks_error(self):
     response = mock.Mock()
     response.json.return_value = {'message': 'Not found'}
     response.status_code = 404
     self.cli.list_tasks.side_effect = exceptions.MarathonHttpError(response)
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'), {})
 def test_fetch_tasks_empty(self):
     self.cli.list_tasks.return_value = []
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'), {})
 def test_fetch_tasks_empty(self):
     self.cli.list_tasks.return_value = []
     self.assertEqual(marathon_client._fetch_tasks(self.cli, 'chronos'), {})