def test_task_list_non_existing_play(self): ansible_run() cmd = ara.cli.task.TaskList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--play', 'foo']) res = cmd.take_action(args) self.assertEqual(res[1], [])
def test_data_show_for_non_existing_data(self): ansible_run(ara_record=True) cmd = ara.cli.data.DataShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['foo']) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_result_list_non_existing_task(self): ansible_run() cmd = ara.cli.result.ResultList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--task', 'foo']) res = cmd.take_action(args) self.assertEqual(res[1], [])
def test_host_list_for_non_existing_playbook(self): ansible_run() cmd = ara.cli.host.HostList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--playbook', 'foo']) res = cmd.take_action(args) self.assertEqual(res[1], [])
def test_playbook_list_incomplete_with_no_incomplete(self): ansible_run() cmd = ara.cli.playbook.PlaybookList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--incomplete']) res = cmd.take_action(args) self.assertEqual(res[1], [])
def test_result_show_long_non_existing(self): ansible_run() cmd = ara.cli.result.ResultShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['foo', '--long']) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_host_show_for_non_existing_host(self): ansible_run() cmd = ara.cli.host.HostShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['foo']) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_data_list_for_non_existing_playbook(self): ansible_run(ara_record=True) cmd = ara.cli.data.DataList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--playbook', 'foo']) res = cmd.take_action(args) self.assertEqual(res[1], [])
def test_playbook_show_non_existing(self): ansible_run() cmd = ara.cli.playbook.PlaybookShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['foo']) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_show_task_status(self): ctx = ansible_run() res = self.client.get('/task/{}?status=ok'.format( ctx['task'].id)) self.assertEqual(res.status_code, 200) self.assertIn('<td>\n<a href="/host/{host}">{host}</a>\n</td>'.format( host=ctx['host'].name), res.get_data())
def test_show_task_status(self): ctx = ansible_run() res = self.client.get('/task/{}/?status=ok'.format(ctx['task'].id)) self.assertEqual(res.status_code, 200) self.assertIn( '<td><a href="/host/{id}/">{host}</a></td>'.format( id=ctx['host'].id, host=ctx['host'].name), res.get_data())
def test_show_task_host(self): ctx = ansible_run() res = self.client.get('/task/{}/?host={}'.format( ctx['task'].id, ctx['host'].name)) self.assertEqual(res.status_code, 200) self.assertIn('<td>\n<a href="/host/{host}/">{host}</a>\n</td>'.format( host=ctx['host'].name), res.get_data())
def test_show_task_host(self): ctx = ansible_run() res = self.client.get('/task/{}/?host={}'.format( ctx['task'].id, ctx['host'].name)) self.assertEqual(res.status_code, 200) self.assertIn('<td><a href="/host/{id}/">{host}</a></td>'.format( id=ctx['host'].id, host=ctx['host'].name), res.get_data())
def test_playbook_list_incomplete(self): ctx = ansible_run(complete=False) cmd = ara.cli.playbook.PlaybookList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--incomplete']) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['playbook'].id)
def test_play_list_all(self): ctx = ansible_run() cmd = ara.cli.play.PlayList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--all']) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['play'].id)
def test_host_fact_existing_host_non_existing_facts(self): ctx = ansible_run(gather_facts=False) cmd = ara.cli.host.HostFacts(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['host'].id]) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_host_fact_non_existing_host(self): ctx = ansible_run() cmd = ara.cli.host.HostFacts(None, None) parser = cmd.get_parser('test') args = parser.parse_args('foo') with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_playbook_show(self): ctx = ansible_run() cmd = ara.cli.playbook.PlaybookShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['playbook'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0], ctx['playbook'].id)
def test_data_show_by_id(self): ctx = ansible_run(ara_record=True) cmd = ara.cli.data.DataShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['data'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0], ctx['data'].id)
def test_result_list_task(self): ctx = ansible_run() cmd = ara.cli.result.ResultList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--task', ctx['task'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['result'].id)
def test_data_list_for_playbook(self): ctx = ansible_run(ara_record=True) cmd = ara.cli.data.DataList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--playbook', ctx['playbook'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['data'].id)
def test_stats_show(self): ctx = ansible_run() cmd = ara.cli.stats.StatsShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['stats'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0], ctx['stats'].id)
def test_stats_show_non_existing(self): ctx = ansible_run() cmd = ara.cli.stats.StatsShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['foo']) with self.assertRaises(RuntimeError): cmd.take_action(args)
def test_host_show_by_id(self): ctx = ansible_run() cmd = ara.cli.host.HostShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['host'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0], ctx['host'].id)
def test_host_list_for_playbook(self): ctx = ansible_run() cmd = ara.cli.host.HostList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--playbook', ctx['playbook'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['host'].id)
def test_task_list_play(self): ctx = ansible_run() cmd = ara.cli.task.TaskList(None, None) parser = cmd.get_parser('test') args = parser.parse_args(['--play', ctx['play'].id]) res = cmd.take_action(args) self.assertEqual(res[1][0][0], ctx['task'].id)
def test_result_show_long(self): ctx = ansible_run() cmd = ara.cli.result.ResultShow(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['result'].id, '--long']) res = cmd.take_action(args) self.assertEqual(res[1][0], ctx['result'].id) self.assertEqual(res[1][-1], json.dumps(ctx['result'].result))
def test_host_fact_by_id(self): ctx = ansible_run() cmd = ara.cli.host.HostFacts(None, None) parser = cmd.get_parser('test') args = parser.parse_args([ctx['host'].id]) res = cmd.take_action(args) facts = json.loads(ctx['facts'].values) self.assertEqual(res, zip(*sorted(six.iteritems(facts))))
def test_get_summary_stats_failed(self): ctx = ansible_run(failed=True) playbook = ctx['playbook'].id res = u.get_summary_stats([ctx['playbook']], 'playbook_id') self.assertEqual(1, res[playbook]['ok']) self.assertEqual(0, res[playbook]['changed']) self.assertEqual(1, res[playbook]['failed']) self.assertEqual(1, res[playbook]['skipped']) self.assertEqual(0, res[playbook]['unreachable']) self.assertEqual('failed', res[playbook]['status'])
def test_get_summary_stats_incomplete(self): ctx = ansible_run(complete=False) playbook = ctx['playbook'].id res = u.get_summary_stats([ctx['playbook']], 'playbook_id') self.assertEqual(0, res[playbook]['ok']) self.assertEqual(0, res[playbook]['changed']) self.assertEqual(0, res[playbook]['failed']) self.assertEqual(0, res[playbook]['skipped']) self.assertEqual(0, res[playbook]['unreachable']) self.assertEqual('incomplete', res[playbook]['status'])
def test_list_playbook_incomplete(self): ansible_run(complete=False) res = self.client.get('/playbook/') self.assertEqual(res.status_code, 200)
def test_list_playbook(self): ansible_run() res = self.client.get('/playbook/') self.assertEqual(res.status_code, 200)
def test_list_host(self): ansible_run() res = self.client.get('/host/') self.assertEqual(res.status_code, 200)
def test_show_result_incomplete(self): ctx = ansible_run(complete=False) res = self.client.get('/result/{}'.format( ctx['result'].id)) self.assertEqual(res.status_code, 200)
def test_show_result_missing(self): ansible_run() res = self.client.get('/result/foo') self.assertEqual(res.status_code, 404)
def test_show_task_missing(self): ansible_run() res = self.client.get('/task/foo/') self.assertEqual(res.status_code, 404)
def test_show_playbook_results_host_status(self): ctx = ansible_run() res = self.client.get('/playbook/{}/results/{}/ok'.format( ctx['playbook'].id, ctx['host'].name)) self.assertEqual(res.status_code, 200)
def test_show_play_missing(self): ctx = ansible_run() res = self.client.get('/play/foo/'.format(ctx['play'].id)) self.assertEqual(res.status_code, 404)
def test_show_play_missing(self): ctx = ansible_run() res = self.client.get('/play/foo'.format( ctx['play'].id)) self.assertEqual(res.status_code, 404)
def test_show_host_missing_facts_missing(self): ansible_run() res = self.client.get('/host/foo/facts/') self.assertEqual(res.status_code, 404)
def test_show_playbook_missing(self): ansible_run() res = self.client.get('/playbook/foo') self.assertEqual(res.status_code, 404)
def test_show_playbook_results_missing(self): ctx = ansible_run() res = self.client.get('/playbook/foo/results/'.format( ctx['playbook'].id)) self.assertEqual(res.status_code, 404)
def test_show_playbook_incomplete(self): ctx = ansible_run(complete=False) res = self.client.get('/playbook/{}'.format( ctx['playbook'].id)) self.assertEqual(res.status_code, 200)
def test_show_host_incomplete(self): ctx = ansible_run(complete=False) res = self.client.get('/host/{}'.format( ctx['host'].name)) self.assertEqual(res.status_code, 200)
def test_show_play(self): ctx = ansible_run() res = self.client.get('/play/{}'.format( ctx['play'].id)) self.assertEqual(res.status_code, 200)
def test_show_result(self): ctx = ansible_run() res = self.client.get('/result/{}/'.format( ctx['result'].id)) self.assertEqual(res.status_code, 200)
def test_show_host_facts(self): ctx = ansible_run() res = self.client.get('/host/{}/facts/'.format( ctx['host'].name)) self.assertEqual(res.status_code, 200)
def test_show_task(self): ctx = ansible_run() res = self.client.get('/task/{}'.format( ctx['task'].id)) self.assertEqual(res.status_code, 200)
def test_show_play_incomplete(self): ctx = ansible_run(complete=False) res = self.client.get('/play/{}/'.format(ctx['play'].id)) self.assertEqual(res.status_code, 200)
def test_show_host_exists_facts_missing(self): ctx = ansible_run(gather_facts=False) res = self.client.get('/host/{}/facts/'.format( ctx['host'].name)) self.assertEqual(res.status_code, 404)