Add unit test file for ArithmeticRunner
[yardstick.git] / yardstick / tests / unit / benchmark / runner / test_arithmetic.py
1 ##############################################################################
2 # Copyright (c) 2018 Nokia and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 import mock
11 import unittest
12 import multiprocessing
13 import os
14
15 from yardstick.benchmark.runners import arithmetic
16
17
18 class ArithmeticRunnerTest(unittest.TestCase):
19     def setUp(self):
20         self.scenario_cfg = {
21             'type': 'some_type'
22         }
23
24     @mock.patch.object(os, 'getpid')
25     @mock.patch.object(multiprocessing, 'Process')
26     def test__run_benchmark_called_with(self, mock_multiprocessing_process,
27                                         mock_os_getpid):
28         mock_os_getpid.return_value = 101
29
30         runner = arithmetic.ArithmeticRunner({})
31         benchmark_cls = mock.Mock()
32         runner._run_benchmark(benchmark_cls, 'my_method', self.scenario_cfg,
33                               {})
34         mock_multiprocessing_process.assert_called_once_with(
35             name='Arithmetic-some_type-101',
36             target=arithmetic._worker_process,
37             args=(runner.result_queue, benchmark_cls, 'my_method',
38                   self.scenario_cfg, {}, runner.aborted, runner.output_queue))