summaryrefslogtreecommitdiffstats
path: root/tests/unit/common
diff options
context:
space:
mode:
authorzhongjun <zhong.jun@zte.com.cn>2017-08-31 21:52:03 +0800
committerzhongjun <zhong.jun@zte.com.cn>2017-08-31 22:14:58 +0800
commit814729059a385d5edb0c19347b3dfa76930220a5 (patch)
treeaad882cbea94f7d7ced43d73430ae265b6d2802d /tests/unit/common
parent91b18eadfb2ca83d9291281210342dfefa7694b2 (diff)
Add some unit test files test_netwrok.py
1.add the below unit test files: test_netwrok.py/test_schemas.py/test_query.py/test_utils.py 2.add the corresponding test conf file deploy_virtual_error.yml. Change-Id: I01292d4c94b9d6159597961a0cab515f57727ec3 Signed-off-by: zhongjun <zhong.jun@zte.com.cn>
Diffstat (limited to 'tests/unit/common')
-rw-r--r--tests/unit/common/test_query.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/common/test_query.py b/tests/unit/common/test_query.py
new file mode 100644
index 00000000..6e580dd7
--- /dev/null
+++ b/tests/unit/common/test_query.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 deploy.common.query import (
+ find
+)
+
+
+@pytest.mark.parametrize('sequence, expected', [
+ ([{'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3', 'end': '10.20.11.10'}],
+ 'name': 'MANAGEMENT'},
+ {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3', 'end': '10.20.11.10'}],
+ 'name': 'STORAGE'}],
+ {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3', 'end': '10.20.11.10'}],
+ 'name': 'STORAGE'}),
+ ([{'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3', 'end': '10.20.11.10'}],
+ 'name': 'MANAGEMENT'},
+ {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3', 'end': '10.20.11.10'}],
+ 'name': 'PUBLICAPI'}],
+ None)])
+def test_find(sequence, expected):
+ def sample_func(item):
+ return item['name'] == 'STORAGE'
+ assert find(sample_func, sequence) == expected