Passed
Push — dev ( 6a1e3c...3c73d5 )
by Konstantinos
01:31
created

test_command_registration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 38
dl 0
loc 47
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B test_command_registrator() 0 44 1
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
    class D(B): pass
10
    classes = (A, B, C, D)
11
12
    assert all([hasattr(x, 'registry') for x in classes])
13
    assert all([type(x) == CommandRegistrator for x in classes])
14
    assert all([hasattr(x, 'state') for x in classes])
15
    assert id(A.registry) != id(B.registry) != id(C.registry) != id(D.registry)
16
17
    A.state = 1
18
    B.state = 2
19
    C.state = 3
20
    D.state = 4
21
    assert id(A.state) != id(B.state) != id(C.state) != id(D.state)
22
23
    A.registry['a'] = 1
24
    B.registry['b'] = 2
25
    C.registry['c'] = 3
26
    D.registry['d'] = 4
27
    assert B.registry != A.registry != C.registry != D.registry
28
29
    assert A.__getitem__('a') == 1
30
    assert B.__getitem__('b') == 2
31
    assert C.__getitem__('c') == 3
32
    assert D.__getitem__('d') == 4
33
    assert 'b' not in C.registry
34
    assert 'c' not in B.registry
35
    assert 'c' not in D.registry
36
    assert 'd' not in C.registry
37
    assert A['a'] == 1
38
    assert B['b'] == 2
39
    assert C['c'] == 3
40
    assert D['d'] == 4
41
42
43
    class P1(CommandRegistrator): pass
44
    assert type(P1) == type
45
    assert not hasattr(P1, 'state')
46
    assert not hasattr(P1, 'state')
47