diff options
author | ashishk1994 <ashishk.iiit@gmail.com> | 2017-02-21 22:53:29 +0530 |
---|---|---|
committer | Ashish Kumar <ashishk.iiit@gmail.com> | 2017-03-15 07:31:04 +0000 |
commit | f651565ffc8979ef99a1d9bc001561bf1fba3779 (patch) | |
tree | 488d904f8fbb9ca245f1b22aab94af7447639885 /functest/tests/unit/ci/test_tier_builder.py | |
parent | 65b26f2e9db7e0cf336c147d46d91cb1c828a67b (diff) |
Added Unit Tests for ci/tier_builder
Change-Id: I66f43fb09472948bc71178cd8aeb14dc1ab5fa55
Signed-off-by: ashishk1994 <ashishk.iiit@gmail.com>
Diffstat (limited to 'functest/tests/unit/ci/test_tier_builder.py')
-rw-r--r-- | functest/tests/unit/ci/test_tier_builder.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/functest/tests/unit/ci/test_tier_builder.py b/functest/tests/unit/ci/test_tier_builder.py new file mode 100644 index 00000000..48c94a57 --- /dev/null +++ b/functest/tests/unit/ci/test_tier_builder.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# 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 logging +import unittest + +import mock + +from functest.ci import tier_builder + + +class TierBuilderTesting(unittest.TestCase): + + logging.disable(logging.CRITICAL) + + def setUp(self): + self.dependency = {'installer': 'test_installer', + 'scenario': 'test_scenario'} + + self.testcase = {'dependencies': self.dependency, + 'name': 'test_name', + 'criteria': 'test_criteria', + 'blocking': 'test_blocking', + 'clean_flag': 'test_clean_flag', + 'description': 'test_desc'} + + self.dic_tier = {'name': 'test_tier', + 'order': 'test_order', + 'ci_loop': 'test_ci_loop', + 'description': 'test_desc', + 'testcases': [self.testcase]} + + self.mock_yaml = mock.Mock() + attrs = {'get.return_value': [self.dic_tier]} + self.mock_yaml.configure_mock(**attrs) + + with mock.patch('functest.ci.tier_builder.yaml.safe_load', + return_value=self.mock_yaml), \ + mock.patch('__builtin__.open', mock.mock_open()): + self.tierbuilder = tier_builder.TierBuilder('test_installer', + 'test_scenario', + 'testcases_file') + self.tier_obj = self.tierbuilder.tier_objects[0] + + def test_get_tiers(self): + self.assertEqual(self.tierbuilder.get_tiers(), + [self.tier_obj]) + + def test_get_tier_names(self): + self.assertEqual(self.tierbuilder.get_tier_names(), + ['test_tier']) + + def test_get_tier_present_tier(self): + self.assertEqual(self.tierbuilder.get_tier('test_tier'), + self.tier_obj) + + def test_get_tier_missing_tier(self): + self.assertEqual(self.tierbuilder.get_tier('test_tier2'), + None) + + def test_get_test_present_test(self): + self.assertEqual(self.tierbuilder.get_test('test_name'), + self.tier_obj.get_test('test_name')) + + def test_get_test_missing_test(self): + self.assertEqual(self.tierbuilder.get_test('test_name2'), + None) + + def test_get_tests_present_tier(self): + self.assertEqual(self.tierbuilder.get_tests('test_tier'), + self.tier_obj.tests_array) + + def test_get_tests_missing_tier(self): + self.assertEqual(self.tierbuilder.get_tests('test_tier2'), + None) + + +if __name__ == "__main__": + unittest.main(verbosity=2) |