summaryrefslogtreecommitdiffstats
path: root/tests/unit/config/test_schemas.py
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/config/test_schemas.py
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/config/test_schemas.py')
-rw-r--r--tests/unit/config/test_schemas.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/unit/config/test_schemas.py b/tests/unit/config/test_schemas.py
new file mode 100644
index 00000000..04705fda
--- /dev/null
+++ b/tests/unit/config/test_schemas.py
@@ -0,0 +1,33 @@
+##############################################################################
+# 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 os
+
+import yaml
+import pytest
+
+from deploy.config.schemas import (
+ deploy_schema_validate
+)
+
+
+@pytest.fixture(scope="session")
+def conf_file_dir(data_root):
+ return os.path.join(data_root, 'lab_conf')
+
+
+@pytest.mark.parametrize('deploy_file_name', [
+ ('deploy_virtual1.yml'),
+ ('deploy_virtual_error.yml')])
+def test_deploy_schema_validate(conf_file_dir, deploy_file_name):
+ data = yaml.safe_load(open(os.path.join(conf_file_dir, deploy_file_name), 'r'))
+ errors = deploy_schema_validate(data)
+ if deploy_file_name == 'deploy_virtual1.yml':
+ assert errors == []
+ elif deploy_file_name == 'deploy_virtual_error.yml':
+ assert errors != []