Passed
Push — dev ( 1b3874...6a1e3c )
by Konstantinos
03:33
created

test_command_registrator()   A

Complexity

Conditions 1

Size

Total Lines 37
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 37
rs 9.16
c 0
b 0
f 0
cc 1
nop 0
1
2
3
def test_command_registrator():
4
    from green_magic.data. commands_manager import CommandRegistrator
5
6
    class A(metaclass=CommandRegistrator): pass
7
    class B(metaclass=CommandRegistrator): pass
8
    class C(B): pass
9
    classes = (A, B, C)
10
11
    assert all([hasattr(x, 'registry') for x in classes])
12
    assert all([type(x) == CommandRegistrator for x in classes])
13
    assert all([hasattr(x, 'state') for x in classes])
14
    assert id(A.registry) != id(B.registry) != id(C.registry)
15
16
    A.state = 1
17
    B.state = 2
18
    C.state = 3
19
    assert id(A.state) != id(B.state) != id(C.state)
20
21
    A.registry['a'] = 1
22
    B.registry['b'] = 2
23
    C.registry['c'] = 3
24
    assert B.registry != A.registry != C.registry
25
26
    assert A.__getitem__('a') == 1
27
    assert B.__getitem__('b') == 2
28
    assert C.__getitem__('c') == 3
29
    assert 'b' not in C.registry
30
    assert 'c' not in B.registry
31
    assert A['a'] == 1
32
    assert B['b'] == 2
33
    assert C['c'] == 3
34
35
36
    class P1(CommandRegistrator): pass
37
    assert type(P1) == type
38
    assert not hasattr(P1, 'state')
39
    assert not hasattr(P1, 'state')
40