mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
0c2bb3da04
* Move docker_ module_utils into subpackage. * Remove docker_ prefix from module_utils.docker modules. * Adding jurisdiction for module_utils/docker to $team_docker. * Making docker* unit tests community supported. * Linting. * Python < 2.6 is not supported. * Refactoring docker-py version comments. Moving them to doc fragments. Cleaning up some indentations.
31 lines
986 B
Python
31 lines
986 B
Python
# Copyright (c) 2018 Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from ansible.modules.cloud.docker import docker_volume
|
|
from ansible.module_utils.docker import common
|
|
|
|
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):
|
|
mocker.patch.object(common, 'HAS_DOCKER_PY', True)
|
|
mocker.patch.object(common, 'docker_version', '1.8.0')
|
|
|
|
with pytest.raises(SystemExit):
|
|
docker_volume.main()
|
|
|
|
out, dummy = capfd.readouterr()
|
|
results = json.loads(out)
|
|
assert results['failed']
|
|
assert 'Error: docker / docker-py version is 1.8.0. Minimum version required is 1.10.0.' in results['msg']
|