summaryrefslogtreecommitdiffstats
path: root/test/TestDeprecatedModule.py
blob: 6741ed48d20e83a1cd4354097eae8e01e232a062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# pylint: disable=preferred-module  # FIXME: remove once migrated per GH-725
import unittest

import pytest

from ansiblelint.rules import RulesCollection
from ansiblelint.rules.DeprecatedModuleRule import DeprecatedModuleRule
from ansiblelint.testing import ANSIBLE_MAJOR_VERSION, RunFromText

MODULE_DEPRECATED = '''
- name: task example
  docker:
    debug: test
'''


class TestDeprecatedModuleRule(unittest.TestCase):
    collection = RulesCollection()
    collection.register(DeprecatedModuleRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    @pytest.mark.xfail(
        ANSIBLE_MAJOR_VERSION > (2, 9),
        reason='Ansible devel has changed so ansible-lint needs fixing. '
        'Ref: https://github.com/ansible/ansible-lint/issues/675',
        raises=SystemExit, strict=True,
    )
    def test_module_deprecated(self):
        results = self.runner.run_role_tasks_main(MODULE_DEPRECATED)
        self.assertEqual(1, len(results))