Esempio n. 1
0
    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], [])
Esempio n. 2
0
    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)
Esempio n. 3
0
    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], [])
Esempio n. 4
0
    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], [])
Esempio n. 5
0
    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], [])
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    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], [])
Esempio n. 9
0
    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)
Esempio n. 10
0
 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())
Esempio n. 11
0
 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())
Esempio n. 12
0
File: test_app.py Progetto: 40a/ara
 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())
Esempio n. 13
0
 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())
Esempio n. 14
0
    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)
Esempio n. 15
0
    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)
Esempio n. 16
0
    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)
Esempio n. 17
0
    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)
Esempio n. 18
0
    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)
Esempio n. 19
0
    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)
Esempio n. 20
0
    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)
Esempio n. 21
0
    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)
Esempio n. 22
0
    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)
Esempio n. 23
0
    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)
Esempio n. 24
0
    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)
Esempio n. 25
0
    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)
Esempio n. 26
0
    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)
Esempio n. 27
0
    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)
Esempio n. 28
0
    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))
Esempio n. 29
0
    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))))
Esempio n. 30
0
    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'])
Esempio n. 31
0
    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'])
Esempio n. 32
0
 def test_list_playbook_incomplete(self):
     ansible_run(complete=False)
     res = self.client.get('/playbook/')
     self.assertEqual(res.status_code, 200)
Esempio n. 33
0
 def test_list_playbook(self):
     ansible_run()
     res = self.client.get('/playbook/')
     self.assertEqual(res.status_code, 200)
Esempio n. 34
0
 def test_list_host(self):
     ansible_run()
     res = self.client.get('/host/')
     self.assertEqual(res.status_code, 200)
Esempio n. 35
0
 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)
Esempio n. 36
0
 def test_show_result_missing(self):
     ansible_run()
     res = self.client.get('/result/foo')
     self.assertEqual(res.status_code, 404)
Esempio n. 37
0
 def test_show_task_missing(self):
     ansible_run()
     res = self.client.get('/task/foo/')
     self.assertEqual(res.status_code, 404)
Esempio n. 38
0
 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)
Esempio n. 39
0
 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)
Esempio n. 40
0
 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)
Esempio n. 41
0
 def test_show_host_missing_facts_missing(self):
     ansible_run()
     res = self.client.get('/host/foo/facts/')
     self.assertEqual(res.status_code, 404)
Esempio n. 42
0
 def test_show_playbook_missing(self):
     ansible_run()
     res = self.client.get('/playbook/foo')
     self.assertEqual(res.status_code, 404)
Esempio n. 43
0
 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)
Esempio n. 44
0
 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)
Esempio n. 45
0
 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)
Esempio n. 46
0
 def test_show_play(self):
     ctx = ansible_run()
     res = self.client.get('/play/{}'.format(
         ctx['play'].id))
     self.assertEqual(res.status_code, 200)
Esempio n. 47
0
 def test_show_result(self):
     ctx = ansible_run()
     res = self.client.get('/result/{}/'.format(
         ctx['result'].id))
     self.assertEqual(res.status_code, 200)
Esempio n. 48
0
 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)
Esempio n. 49
0
 def test_show_task(self):
     ctx = ansible_run()
     res = self.client.get('/task/{}'.format(
         ctx['task'].id))
     self.assertEqual(res.status_code, 200)
Esempio n. 50
0
 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)
Esempio n. 51
0
 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)