Add some other tests to ApexLake
[yardstick.git] / yardstick / vTC / apexlake / tests / experiment_test.py
1 # Copyright (c) 2015 Intel Research and Development Ireland Ltd.
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 __author__ = 'gpetralx'
16
17 import unittest
18 from experimental_framework import data_manager
19
20
21 class TestExperiment(unittest.TestCase):
22     def setUp(self):
23         self.exp = data_manager.Experiment('experiment_1')
24
25     def tearDown(self):
26         pass
27
28     def test_add_experiment_metadata(self):
29         with self.assertRaises(ValueError):
30             self.exp.add_experiment_metadata('metadata')
31
32         metadata = {
33             'item_1': 'value_1',
34             'item_2': 'value_2',
35             'item_3': 'value_3'
36         }
37         self.exp.add_experiment_metadata(metadata)
38         self.assertDictEqual(metadata, self.exp._metadata)
39         self.assertDictEqual(metadata, self.exp.get_metadata())
40
41     def test_experiment_configuration(self):
42         with self.assertRaises(ValueError):
43             self.exp.add_experiment_configuration('configuration')
44         configuration = {
45             'item_1': 'value_1',
46             'item_2': 'value_2',
47             'item_3': 'value_3'
48         }
49         self.exp.add_experiment_configuration(configuration)
50         self.assertDictEqual(configuration, self.exp._configuration)
51         self.assertDictEqual(configuration, self.exp.get_configuration())
52
53     def test_add_benchmark(self):
54         with self.assertRaises(ValueError):
55             self.exp.add_benchmark(1)
56         self.exp.add_benchmark('benchmark_1')
57         self.assertListEqual(list(), self.exp._benchmarks['benchmark_1'])
58
59     def test_add_datapoint(self):
60         with self.assertRaises(ValueError):
61             self.exp.add_data_point('benchmark_1', 'datapoint')
62
63         data_point_1 = {
64             'point_1': 'value_1',
65             'point_2': 'value_2',
66             'point_3': 'value_3'
67         }
68
69         with self.assertRaises(ValueError):
70             self.exp.add_data_point('benchmark_1', data_point_1)
71
72         self.exp.add_benchmark('benchmark_1')
73         self.exp.add_data_point('benchmark_1', data_point_1)
74         self.assertListEqual([data_point_1],
75                              self.exp._benchmarks['benchmark_1'])
76
77     def test_get_data_points(self):
78         self.assertListEqual(list(), self.exp.get_data_points('benchmark_1'))
79         data_point_1 = {
80             'point_1': 'value_1',
81             'point_2': 'value_2',
82             'point_3': 'value_3'
83         }
84         self.exp.add_benchmark('benchmark_1')
85         self.exp.add_data_point('benchmark_1', data_point_1)
86         self.assertListEqual([data_point_1],
87                              self.exp.get_data_points('benchmark_1'))
88
89     def test_get_benchmarks(self):
90         self.exp.add_benchmark('benchmark_1')
91         self.exp.add_benchmark('benchmark_2')
92         self.exp.add_benchmark('benchmark_3')
93         expected = ['benchmark_3', 'benchmark_2', 'benchmark_1']
94         self.assertListEqual(expected, self.exp.get_benchmarks())