TestCycleCallback   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _cycle_callback() 0 3 1
A test_cycles_callbacks() 0 8 1
A _get_set_up_simulations() 0 2 1
1
from synergine.test.TestSimulation import TestSimulation as BaseTestSimulation
2
from tests.src.TestCollection import TestCollection
3
from tests.src.TestSimulation import TestSimulation as TestSimulationSimulation
4
from tests.src.TestCollectionConfiguration import TestCollectionConfiguration
5
6
7
class TestCycleCallback(BaseTestSimulation):
8
9
    _callback_call_count = -1
10
11
    def _get_set_up_simulations(self):
12
        return [TestSimulationSimulation([TestCollection(TestCollectionConfiguration())])]
13
14
    def test_cycles_callbacks(self):
15
        self._connection.receive_callback = self._cycle_callback
16
17
        self._callback_call_count = -1
18
        core = self.get_core(5)
19
        core.run()
20
21
        self.assertEquals(5, self._callback_call_count)
22
23
    def _cycle_callback(self, terminal, actions_done):
24
        self._callback_call_count += 1
25
        self.assertEquals(self._callback_call_count, terminal.get_context().get_cycle())
26