|
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.input_vector[2] += 1 |
|
29
|
|
|
self.assertEqual(tested_object.input_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
|
|
|
|
|
49
|
|
|
def test_is_enough_quality(self): |
|
50
|
|
|
"""Check is_enough_quality method.""" |
|
51
|
|
|
tested_object = AbstractStage() |
|
52
|
|
|
with self.assertRaises(NotImplementedError): |
|
53
|
|
|
tested_object.is_enough_quality(7) |
|
54
|
|
|
|
|
55
|
|
|
def test_get_output_of_stage(self): |
|
56
|
|
|
"""Check is_enough_quality method.""" |
|
57
|
|
|
tested_object = AbstractStage() |
|
58
|
|
|
with self.assertRaises(NotImplementedError): |
|
59
|
|
|
tested_object.get_output_of_stage() |
|
60
|
|
|
|
|
61
|
|
|
def test_get_maximal_acceptable_cost(self): |
|
|
|
|
|
|
62
|
|
|
tested_object = AbstractStage() |
|
63
|
|
|
with self.assertRaises(NotImplementedError): |
|
64
|
|
|
tested_object.get_maximal_acceptable_cost() |
|
65
|
|
|
|
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.