1
|
|
|
"""Module for testing.""" |
2
|
|
|
|
3
|
|
|
from unittest import TestCase |
4
|
|
|
from unittest.mock import Mock |
5
|
|
|
|
6
|
|
|
from grortir.main.model.core.abstract_stage import AbstractStage |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class TestAbstractStage(TestCase): |
10
|
|
|
"""Class for testing AbstractStage.""" |
11
|
|
|
|
12
|
|
|
def test___init__(self): |
13
|
|
|
"""Constructor test.""" |
14
|
|
|
tested_object = AbstractStage() |
15
|
|
|
self.assertIsNotNone(tested_object) |
16
|
|
|
|
17
|
|
|
def test___init__arguments_passed(self): |
18
|
|
|
"""Check arguments in constructor.""" |
19
|
|
|
abstract_stage_mock = Mock() |
20
|
|
|
input_vector = (1, 2, 3) |
21
|
|
|
AbstractStage.__init__(abstract_stage_mock, input_vector) |
22
|
|
|
self.assertEqual(abstract_stage_mock.input_vector, input_vector) |
23
|
|
|
|
24
|
|
|
def test___init__output_mutability(self): |
25
|
|
|
"""Check fields in object.""" |
26
|
|
|
input_vector = (1, 2, 3) |
27
|
|
|
tested_object = AbstractStage(input_vector) |
28
|
|
|
tested_object.current_vector[2] += 1 |
29
|
|
|
self.assertEqual(tested_object.current_vector[2], 4) |
30
|
|
|
|
31
|
|
|
def test_get_cost(self): |
32
|
|
|
"""Check get_cost method.""" |
33
|
|
|
tested_object = AbstractStage() |
34
|
|
|
with self.assertRaises(NotImplementedError): |
35
|
|
|
tested_object.get_cost() |
36
|
|
|
|
37
|
|
|
def test_get_quality(self): |
38
|
|
|
"""Check get_quality method.""" |
39
|
|
|
tested_object = AbstractStage() |
40
|
|
|
with self.assertRaises(NotImplementedError): |
41
|
|
|
tested_object.get_quality() |
42
|
|
|
|
43
|
|
|
def test_could_be_optimized(self): |
44
|
|
|
"""Check could_be_optimized method.""" |
45
|
|
|
tested_object = AbstractStage() |
46
|
|
|
with self.assertRaises(NotImplementedError): |
47
|
|
|
tested_object.could_be_optimized() |
48
|
|
|
|