Completed
Push — master ( 40c094...b6a1c4 )
by Wojtek
02:30
created

TestBaseOptimizer.setUp()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
1
from unittest import TestCase
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from grortir.main.model.core.abstract_process import AbstractProcess
4
from grortir.main.model.core.abstract_stage import AbstractStage
5
from grortir.main.optimizers.base_optimizer import BaseOptimizer
6
7
8
class TestBaseOptimizer(TestCase):
9
    """Class for testing Optimizer."""
10
11
    def setUp(self):
12
        """Set up environment."""
13
        self.some_process = AbstractProcess()
14
        self.first_stage = AbstractStage()
15
        self.second_stage = AbstractStage()
16
        self.some_process.add_path([self.first_stage, self.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...
17
18
    def test___init__(self):
19
        """Testing creating object."""
20
        optimizer = BaseOptimizer(self.some_process)
21
        self.assertIsNotNone(optimizer)
22
        self.assertEqual(optimizer.process, self.some_process)
23
24
    def test_set_order(self):
25
        """Test changing order of optimizing."""
26
        optimizer = BaseOptimizer(self.some_process)
27
        optimizer.set_custom_optimizing_order(
28
            [self.second_stage, self.first_stage])
29
        self.assertEqual(optimizer.ordered_stages[0], self.second_stage)
30
31
    def test_set_order_fail(self):
32
        """Test changing order of optimizing with incorrect list."""
33
        optimizer = BaseOptimizer(self.some_process)
34
        with self.assertRaises(ValueError):
35
            optimizer.set_custom_optimizing_order(
36
                [self.second_stage, self.first_stage, self.first_stage])
37
38
    def test_optimize_process(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
39
        optimizer = BaseOptimizer(self.some_process)
40
        with self.assertRaises(NotImplementedError):
41
            optimizer.optimize_process()
42