summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/parser/test_parser.py
diff options
context:
space:
mode:
authorkubi <jean.gaoliang@huawei.com>2015-12-29 11:04:20 +0800
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2016-01-09 06:06:52 +0000
commit9b792a92f1f0b67159de52f8bd6b94806b35ae7b (patch)
tree840ebf964154f0c2925097a16a43ce07d60050d4 /tests/unit/benchmark/scenarios/parser/test_parser.py
parent20edb26aff8165996bab6f644e7380260a8a0aa5 (diff)
running Parser Yang-to-Tosca module as a tool
with jnon and fatih's help, new docker image has been uploaded so this part is about parser verify validating output against expected outcome. Change-Id: If50d241a5338888f14fd11a752dc72678e0c569b JIRA:YARDSTICK-224 Signed-off-by: kubi <jean.gaoliang@huawei.com> (cherry picked from commit d93f6ca5bf0d4f22ec0fd90eac1bf8b9c09db820)
Diffstat (limited to 'tests/unit/benchmark/scenarios/parser/test_parser.py')
-rw-r--r--tests/unit/benchmark/scenarios/parser/test_parser.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/benchmark/scenarios/parser/test_parser.py b/tests/unit/benchmark/scenarios/parser/test_parser.py
new file mode 100644
index 000000000..d11a6d5c8
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/parser/test_parser.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
+#
+# 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
+##############################################################################
+
+# Unittest for yardstick.benchmark.scenarios.parser.Parser
+
+import mock
+import unittest
+import json
+
+from yardstick.benchmark.scenarios.parser import parser
+
+@mock.patch('yardstick.benchmark.scenarios.parser.parser.subprocess')
+class ParserTestCase(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_parser_successful_setup(self, mock_subprocess):
+
+ p = parser.Parser({}, {})
+ mock_subprocess.call().return_value = 0
+ p.setup()
+ self.assertEqual(p.setup_done, True)
+
+ def test_parser_successful(self, mock_subprocess):
+ args = {
+ 'options': {'yangfile':'/root/yardstick/samples/yang.yaml',
+ 'toscafile':'/root/yardstick/samples/tosca.yaml'},
+ }
+ p = parser.Parser(args, {})
+ result = {}
+ mock_subprocess.call().return_value = 0
+ sample_output = '{"yangtotosca": "success"}'
+
+ p.run(result)
+ expected_result = json.loads(sample_output)
+
+ def test_parser_teardown_successful(self, mock_subprocess):
+
+ p = parser.Parser({}, {})
+ mock_subprocess.call().return_value = 0
+ p.teardown()
+ self.assertEqual(p.teardown_done, True)
+
+
+def main():
+ unittest.main()
+
+if __name__ == '__main__':
+ main()