Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cognifloyd/8e5d0d6015ab0ec0ca87c00d27d5b6e8 to your computer and use it in GitHub Desktop.
Save cognifloyd/8e5d0d6015ab0ec0ca87c00d27d5b6e8 to your computer and use it in GitHub Desktop.
testing the actions/lib/ansible_base.py:AnsibleBaseRunner._parse_extra_vars()
from __future__ import print_function
import unittest
import yaml
from mock import patch
from lib.ansible_base import AnsibleBaseRunner
class TestActionsLibAnsibleBaseRunner(unittest.TestCase):
# from the ActiveDirectory test of a python action
# def load_yaml(self, filename):
# return yaml.safe_load(self.get_fixture_content(filename))
def setUp(self):
super(TestActionsLibAnsibleBaseRunner, self).setUp()
def test_init(self):
args = ['ansible_base.py', '--arg1', '--arg2', 'value2', '--arg3=value3']
ansible_base_runner = AnsibleBaseRunner(args)
self.assertEqual(ansible_base_runner.args, args[1:])
# AnsibleBaseRunner._parse_extra_vars()
def test_parse_extra_vars_key_value(self):
args = ['ansible_base.py',
'--extra_vars=[u"key1=value1", u"key2=value2"]',
]
ansible_base_runner = AnsibleBaseRunner(args)
print(args)
self.assertIn('--extra-vars=key1=value1 key2=value2', ansible_base_runner.args)
# def test_parse_extra_vars_at_file(self):
# self.assertEqual(True, False)
# def test_parse_extra_vars_json(self):
# self.assertEqual(True, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment