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

TestGroupingStrategy.test_define_group_success()   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
"""Testing grouping strategy."""
2
from unittest import TestCase
3
from unittest.mock import Mock
4
5
from grortir.main.optimizers.grouping_strategy import GroupingStrategy
6
7
8
class TestGroupingStrategy(TestCase):
0 ignored issues
show
Coding Style introduced by
This class 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...
9
    def setUp(self):
10
        self.stage_1 = Mock()
11
        self.stage_2 = Mock()
12
        self.stage_3 = Mock()
13
        self.ordered_stages = [self.stage_1, self.stage_2, self.stage_3]
14
        self.tested_object = GroupingStrategy(self.ordered_stages)
15
16
    def test___init__(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...
17
        grouping_strategy = GroupingStrategy([])
18
        self.assertIsNotNone(grouping_strategy)
19
20
    def test_define_group_success(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...
21
        self.perform_simple_grouping()
22
        self.assertEqual(self.tested_object.groups[self.stage_1], 0)
23
        self.assertEqual(self.tested_object.groups[self.stage_2], 1)
24
        self.assertEqual(self.tested_object.groups[self.stage_3], 1)
25
26
    def perform_simple_grouping(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...
27
        self.tested_object.define_group((self.stage_1,))
28
        self.tested_object.define_group((self.stage_2, self.stage_3))
29
30
    def test_define_group_failed(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...
31
        self.tested_object.define_group((self.stage_1,))
32
        with self.assertRaisesRegex(ValueError, "Stage already added."):
33
            self.tested_object.define_group((self.stage_1,))
34
35
    def test_define_group_failed_not_cons(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_define_group_failed_not_cons does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
36
        with self.assertRaisesRegex(ValueError,
37
                                    "Stage not considered in strategy."):
38
            self.tested_object.define_group((Mock(),))
39
40
    def test_get_actual_number_of_groups_0(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_get_actual_number_of_groups_0 does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
41
        tested_strategy = GroupingStrategy([self.stage_1, self.stage_2])
42
        result = tested_strategy.get_actual_numbers_of_groups()
43
        self.assertEqual(result, 0)
44
45
    def test_get_actual_number_of_groups_2(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_get_actual_number_of_groups_2 does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
46
        self.perform_simple_grouping()
47
        result = self.tested_object.get_actual_numbers_of_groups()
48
        self.assertEqual(result, 2)
49
50
    def test_get_items_from_the_same_group_1(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_get_items_from_the_same_group_1 does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
51
        self.perform_simple_grouping()
52
        result = self.tested_object.get_items_from_the_same_group(self.stage_1)
53
        self.assertListEqual(result, [self.stage_1])
54
55
    def test_get_items_from_the_same_group_2(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_get_items_from_the_same_group_2 does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
56
        self.perform_simple_grouping()
57
        result = self.tested_object.get_items_from_the_same_group(self.stage_2)
58
        self.assertEqual(set(result), set([self.stage_2, self.stage_3]))
59
60
    def test_get_items_from_the_same_group_0(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_get_items_from_the_same_group_0 does not conform to the method naming conventions ([a-z_][a-z0-9_]{2,30}$).

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.

Loading history...
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...
61
        with self.assertRaises(ValueError):
62
            self.tested_object.get_items_from_the_same_group(Mock())
63