From ac817f235c0ecf387fda3e859576e7bb6043ff6f Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 16 Feb 2016 12:06:34 +0000 Subject: [PATCH] unit test polishing Add YottaModule unit tests --- mbed_greentea/mbed_yotta_module_parse.py | 2 +- test/mbed_gt_yotta_config.py | 3 +- test/mbed_gt_yotta_module.py | 70 ++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 test/mbed_gt_yotta_module.py diff --git a/mbed_greentea/mbed_yotta_module_parse.py b/mbed_greentea/mbed_yotta_module_parse.py index 6de216b8..c8d3b805 100644 --- a/mbed_greentea/mbed_yotta_module_parse.py +++ b/mbed_greentea/mbed_yotta_module_parse.py @@ -100,7 +100,7 @@ def init(self): self.__yotta_module = {} return bool(len(self.__yotta_module)) - def set_yotta_config(self, yotta_module): + def set_yotta_module(self, yotta_module): self.__yotta_module = yotta_module def get_data(self): diff --git a/test/mbed_gt_yotta_config.py b/test/mbed_gt_yotta_config.py index 8bfd9cfd..191a36c1 100644 --- a/test/mbed_gt_yotta_config.py +++ b/test/mbed_gt_yotta_config.py @@ -17,7 +17,8 @@ """ import unittest -from mbed_greentea.mbed_yotta_target_parse import YottaConfig +from mbed_greentea.mbed_yotta_module_parse import YottaConfig + class YOttaConfigurationParse(unittest.TestCase): diff --git a/test/mbed_gt_yotta_module.py b/test/mbed_gt_yotta_module.py new file mode 100644 index 00000000..f83564ec --- /dev/null +++ b/test/mbed_gt_yotta_module.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +""" +mbed SDK +Copyright (c) 2011-2015 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import unittest +from mbed_greentea.mbed_yotta_module_parse import YottaModule + + +class YOttaConfigurationParse(unittest.TestCase): + + def setUp(self): + self.YOTTA_MODULE_LONG = { + "name": "utest", + "version": "1.9.1", + "description": "Simple test harness with unity and greentea integration.", + "keywords": [ + "greentea", + "testing", + "unittest", + "unity", + "unit", + "test", + "asynchronous", + "async", + "mbed-official" + ], + "author": "Niklas Hauser ", + "license": "Apache-2.0", + "dependencies": { + "minar": "^1.0.0", + "core-util": "^1.0.1", + "compiler-polyfill": "^1.2.0", + "mbed-drivers": "~0.12.0", + "greentea-client": "^0.1.2" + }, + "testDependencies": { + "unity": "^2.0.1", + "greentea-client": "^0.1.2" + } + } + + self.yotta_module = YottaModule() + self.yotta_module.set_yotta_module(self.YOTTA_MODULE_LONG) + + def tearDown(self): + pass + + def test_get_name(self): + self.assertEqual('utest', self.yotta_module.get_name()) + + def test_get_dict_items(self): + self.assertEqual('Simple test harness with unity and greentea integration.', self.yotta_module.get_data().get('description')) + self.assertEqual('Apache-2.0', self.yotta_module.get_data().get('license')) + +if __name__ == '__main__': + unittest.main()