2017-10-09 19:01:21 +02:00
|
|
|
import json
|
|
|
|
|
|
|
|
from ansible.compat.tests import unittest
|
|
|
|
from ansible.compat.tests.mock import patch
|
|
|
|
from ansible.module_utils import basic
|
|
|
|
|
|
|
|
from ansible.modules.packaging.language import pip
|
|
|
|
|
2017-11-17 18:17:07 +01:00
|
|
|
from units.modules.utils import set_module_args, AnsibleFailJson, ModuleTestCase
|
2017-10-09 19:01:21 +02:00
|
|
|
|
|
|
|
|
2017-11-17 18:17:07 +01:00
|
|
|
class TestPip(ModuleTestCase):
|
2017-10-09 19:01:21 +02:00
|
|
|
def setUp(self):
|
2017-11-17 18:17:07 +01:00
|
|
|
super(TestPip, self).setUp()
|
2017-10-09 19:01:21 +02:00
|
|
|
|
|
|
|
@patch.object(basic.AnsibleModule, 'get_bin_path')
|
|
|
|
def test_failure_when_pip_absent(self, mock_get_bin_path):
|
|
|
|
|
|
|
|
mock_get_bin_path.return_value = None
|
|
|
|
|
|
|
|
with self.assertRaises(AnsibleFailJson):
|
|
|
|
set_module_args({'name': 'six'})
|
|
|
|
pip.main()
|