Completed
Pull Request — master (#36)
by Wojtek
09:58
created

TestOptimizer.test___init__()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
1
"""Module for testing optimizer."""
2
3
from unittest import TestCase
4
5
from grortir.main.model.core.abstract_process import AbstractProcess
6
from grortir.main.model.core.abstract_stage import AbstractStage
7
from grortir.main.optimizers.optimizer import Optimizer
8
9
SOME_PROCESS = AbstractProcess()
10
FIRST_STAGE = AbstractStage()
11
SECOND_STAGE = AbstractStage()
12
SOME_PROCESS.add_path([FIRST_STAGE, SECOND_STAGE])
0 ignored issues
show
Bug introduced by
The Instance of AbstractProcess does not seem to have a member named add_path.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
13
14
15
class TestOptimizer(TestCase):
16
    """Class for testing Optimizer."""
17
18
    def test___init__(self):
19
        """Testing creating object."""
20
        optimizer = Optimizer(SOME_PROCESS)
21
        self.assertIsNotNone(optimizer)
22
        self.assertEqual(optimizer.process, SOME_PROCESS)
23
24
    def test_set_order(self):
25
        """Test changing order of optimizing."""
26
        optimizer = Optimizer(SOME_PROCESS)
27
        optimizer.set_custom_optimizing_order([SECOND_STAGE, FIRST_STAGE])
28
        self.assertEqual(optimizer.ordered_stages[0], SECOND_STAGE)
29
30
    def test_set_order_fail(self):
31
        """Test changing order of optimizing with incorrect list."""
32
        optimizer = Optimizer(SOME_PROCESS)
33
        with self.assertRaises(ValueError):
34
            optimizer.set_custom_optimizing_order(
35
                [SECOND_STAGE, FIRST_STAGE, FIRST_STAGE])
36