aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-07 07:32:00 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-04-07 07:32:00 +0000
commit1189453319e6a6994cfd7aa9c891d748337c191c (patch)
treeffd37d242cc881ac7aae77f57937bdcb3e7349dd /tests
parent02e2c3372a654ffeb6cb34c6a0076da51cb568ea (diff)
parentc6c68d91a08dc9315da8c209e2046e9a0300c997 (diff)
Merge "Add ansible action plugin `collect`"
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/ansible_library/plugins/action/collect_test.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/ansible_library/plugins/action/collect_test.py b/tests/unit/ansible_library/plugins/action/collect_test.py
new file mode 100644
index 00000000..5a9fc8f5
--- /dev/null
+++ b/tests/unit/ansible_library/plugins/action/collect_test.py
@@ -0,0 +1,36 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corp and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import pytest
+
+from qtip.ansible_library.plugins.action import collect
+
+
+@pytest.fixture
+def string():
+ return """Lorem ipsum dolor sit amet,
+consectetur adipiscing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+Ut enim ad minim veniam,
+quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+
+Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+"""
+
+
+@pytest.mark.parametrize("patterns,expected", [
+ ('not exist', {}),
+ ('Lorem (\S+)', {}),
+ ('nisi ut (?P<name>\S+)', {'name': ['aliquip']}),
+ ('in\s(?P<in>\w+)', {'in': ['reprehenderit', 'voluptate', 'culpa']})
+])
+def test_collect(patterns, string, expected):
+ assert collect.collect(patterns, string) == expected