mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
2 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
import subprocess
|
||
|
import unittest
|
||
|
|
||
|
|
||
|
class OptionsTest(unittest.TestCase):
|
||
|
options = (
|
||
|
'unsupported',
|
||
|
'disabled',
|
||
|
'unstable',
|
||
|
'destructive',
|
||
|
)
|
||
|
|
||
|
def test_options(self):
|
||
|
for option in self.options:
|
||
|
with self.subTest(option=option):
|
||
|
try:
|
||
|
command = ['ansible-test', 'integration', '--list-targets']
|
||
|
|
||
|
skip_all = subprocess.run([*command, f'{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||
|
allow_all = subprocess.run([*command, f'--allow-{option}', f'{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||
|
allow_first = subprocess.run([*command, f'{option}/{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||
|
allow_last = subprocess.run([*command, f'{option}_a', f'{option}/{option}_b'], text=True, capture_output=True, check=True)
|
||
|
|
||
|
self.assertEqual(skip_all.stdout.splitlines(), [])
|
||
|
self.assertEqual(allow_all.stdout.splitlines(), [f'{option}_a', f'{option}_b'])
|
||
|
self.assertEqual(allow_first.stdout.splitlines(), [f'{option}_a'])
|
||
|
self.assertEqual(allow_last.stdout.splitlines(), [f'{option}_b'])
|
||
|
except subprocess.CalledProcessError as ex:
|
||
|
raise Exception(f'{ex}:\n>>> Standard Output:\n{ex.stdout}\n>>> Standard Error:\n{ex.stderr}') from ex
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|