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.
15 __author__ = 'gpetralx'
18 from experimental_framework import data_manager
21 class TestExperiment(unittest.TestCase):
23 self.exp = data_manager.Experiment('experiment_1')
28 def test_add_experiment_metadata(self):
29 with self.assertRaises(ValueError):
30 self.exp.add_experiment_metadata('metadata')
37 self.exp.add_experiment_metadata(metadata)
38 self.assertDictEqual(metadata, self.exp._metadata)
39 self.assertDictEqual(metadata, self.exp.get_metadata())
41 def test_experiment_configuration(self):
42 with self.assertRaises(ValueError):
43 self.exp.add_experiment_configuration('configuration')
49 self.exp.add_experiment_configuration(configuration)
50 self.assertDictEqual(configuration, self.exp._configuration)
51 self.assertDictEqual(configuration, self.exp.get_configuration())
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'])
59 def test_add_datapoint(self):
60 with self.assertRaises(ValueError):
61 self.exp.add_data_point('benchmark_1', 'datapoint')
69 with self.assertRaises(ValueError):
70 self.exp.add_data_point('benchmark_1', data_point_1)
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'])
77 def test_get_data_points(self):
78 self.assertListEqual(list(), self.exp.get_data_points('benchmark_1'))
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'))
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())