1 # Copyright (c) 2015 Intel Research and Development Ireland Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from __future__ import absolute_import
18 from experimental_framework.benchmarks import benchmark_base_class as base
21 class DummyBechmarkBaseClass(base.BenchmarkBaseClass):
23 def get_features(self):
25 features['description'] = '***'
26 features['parameters'] = ['A', 'B']
27 features['allowed_values'] = dict()
28 features['allowed_values']['A'] = ['a']
29 features['allowed_values']['B'] = ['b']
30 features['default_values'] = dict()
31 features['default_values']['A'] = 'a'
32 features['default_values']['B'] = 'b'
36 class TestBenchmarkBaseClass(unittest.TestCase):
39 self.mut = base.BenchmarkBaseClass('name', dict())
41 def test_constructor_for_success(self):
47 bench_base = DummyBechmarkBaseClass(name, params)
48 self.assertEqual(name, bench_base.name)
49 self.assertIn('A', list(bench_base.params.keys()))
50 self.assertIn('B', list(bench_base.params.keys()))
51 self.assertEqual('a', bench_base.params['A'])
52 self.assertEqual('b', bench_base.params['B'])
57 bench_base = DummyBechmarkBaseClass(name, params)
58 # self.assertEqual(name, bench_base.name)
59 # self.assertIn('A', bench_base.params.keys())
60 # self.assertIn('B', bench_base.params.keys())
61 # self.assertEqual('a', bench_base.params['A'])
62 # self.assertEqual('b', bench_base.params['B'])
64 def test_constructor_for_failure(self):
67 self.assertRaises(ValueError, DummyBechmarkBaseClass, name, params)
69 def test_constructor_for_failure_2(self):
74 self.assertRaises(ValueError, DummyBechmarkBaseClass, name, params)
76 def test_init_for_failure(self):
77 self.assertRaises(NotImplementedError, self.mut.init)
79 def test_finalize_for_failure(self):
80 self.assertRaises(NotImplementedError, self.mut.finalize)
82 def test_run_for_failure(self):
83 self.assertRaises(NotImplementedError, self.mut.run)
85 def test_get_name_for_success(self):
86 self.assertEqual(self.mut.get_name(), 'name')