summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-test-integration-targets/test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/ansible-test-integration-targets/test.py
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/ansible-test-integration-targets/test.py')
-rwxr-xr-xtest/integration/targets/ansible-test-integration-targets/test.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-test-integration-targets/test.py b/test/integration/targets/ansible-test-integration-targets/test.py
new file mode 100755
index 0000000..443ed59
--- /dev/null
+++ b/test/integration/targets/ansible-test-integration-targets/test.py
@@ -0,0 +1,35 @@
+#!/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()