TestActionManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_action_manager() 0 15 2
A _get_class_name_representation() 0 8 3
1
import unittest
2
from synergine.core.ActionManager import ActionManager
3
from tests.src.event.test_actions import A,B,C,D,E,F,G,H
4
from random import shuffle
5
6
7
class TestActionManager(unittest.TestCase):
8
9
    def test_action_manager(self):
10
        action_manager = ActionManager()
11
        actions = [A, B, C, D, E, F, G, H]
12
        steps_correct_order = [
13
            ['A', 'D', 'G'],
14
            ['B'],
15
            ['C', 'H'],
16
            ['F'],
17
            ['E']
18
        ]
19
        self.assertEqual(steps_correct_order, self._get_class_name_representation(action_manager.get_steps_for_actions(actions)))
20
21
        for i in range(10):
22
            shuffle(actions)
23
            self.assertEqual(steps_correct_order, self._get_class_name_representation(action_manager.get_steps_for_actions(actions)))
24
25
    def _get_class_name_representation(self, steps):
26
        steps_representation = []
27
        for step in steps:
28
            step_representation = []
29
            for action in step:
30
                step_representation.append(action.__name__)
31
            steps_representation.append(sorted(step_representation))
32
        return steps_representation