summaryrefslogtreecommitdiffstats
path: root/test/units/module_utils/common/test_removed.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
commita453ac31f3428614cceb99027f8efbdb9258a40b (patch)
treef61f87408f32a8511cbd91799f9cececb53e0374 /test/units/module_utils/common/test_removed.py
parentInitial commit. (diff)
downloadansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz
ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/units/module_utils/common/test_removed.py')
-rw-r--r--test/units/module_utils/common/test_removed.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/units/module_utils/common/test_removed.py b/test/units/module_utils/common/test_removed.py
new file mode 100644
index 00000000..36c1c1e9
--- /dev/null
+++ b/test/units/module_utils/common/test_removed.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
+# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import pytest
+
+from ansible.module_utils.common.removed import removed_module
+
+
+@pytest.mark.parametrize('input_data', [u'2.8', 2.8, 2, '', ])
+def test_removed_module_sys_exit(input_data):
+ """Test for removed_module function, sys.exit()."""
+
+ with pytest.raises(SystemExit) as wrapped_e:
+ removed_module(input_data)
+
+ assert wrapped_e.type == SystemExit
+ assert wrapped_e.value.code == 1
+
+
+@pytest.mark.parametrize(
+ 'input_data, expected_msg, expected_warn',
+ [
+ (
+ u'2.8',
+ u'This module has been removed. '
+ 'The module documentation for Ansible-2.7 may contain hints for porting',
+ u'',
+ ),
+ (
+ 2.8,
+ u'This module has been removed. '
+ 'The module documentation for Ansible-2.7 may contain hints for porting',
+ u'',
+ ),
+ (
+ 2,
+ u'This module has been removed. '
+ 'The module documentation for Ansible-1 may contain hints for porting',
+ u'',
+ ),
+ (
+ u'café',
+ u'This module has been removed',
+ u'"warnings": ["removed modules should specify the version they were removed in"]',
+ ),
+ (
+ 0.1,
+ u'This module has been removed. '
+ 'The module documentation for Ansible-0.0 may contain hints for porting',
+ u'',
+ ),
+ ]
+)
+def test_removed_module_msgs(input_data, expected_msg, expected_warn, capsys):
+ """Test for removed_module function, content of output messages."""
+
+ captured = capsys.readouterr()
+ assert expected_msg, expected_warn in captured.out