2018-11-07 13:31:12 +00:00
|
|
|
# Copyright (c) 2018 Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2019-08-09 21:50:11 +00:00
|
|
|
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
|
2018-11-07 13:31:12 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from ansible.modules.cloud.docker import docker_volume
|
2019-02-08 08:16:11 +00:00
|
|
|
from ansible.module_utils.docker import common
|
2018-11-07 13:31:12 +00:00
|
|
|
|
|
|
|
pytestmark = pytest.mark.usefixtures('patch_ansible_module')
|
|
|
|
|
|
|
|
TESTCASE_DOCKER_VOLUME = [
|
|
|
|
{
|
|
|
|
'name': 'daemon_config',
|
|
|
|
'state': 'present'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_DOCKER_VOLUME, indirect=['patch_ansible_module'])
|
|
|
|
def test_create_volume_on_invalid_docker_version(mocker, capfd):
|
2019-02-08 08:16:11 +00:00
|
|
|
mocker.patch.object(common, 'HAS_DOCKER_PY', True)
|
|
|
|
mocker.patch.object(common, 'docker_version', '1.8.0')
|
2018-11-07 13:31:12 +00:00
|
|
|
|
|
|
|
with pytest.raises(SystemExit):
|
|
|
|
docker_volume.main()
|
|
|
|
|
|
|
|
out, dummy = capfd.readouterr()
|
|
|
|
results = json.loads(out)
|
|
|
|
assert results['failed']
|
2019-06-23 10:27:33 +00:00
|
|
|
assert 'Error: Docker SDK for Python version is 1.8.0 ' in results['msg']
|
|
|
|
assert 'Minimum version required is 1.10.0.' in results['msg']
|