a b/python/tests/test_packet.py
1
# -*- encoding: utf-8 -*-
2
3
from emokit.emotiv import EmotivPacket
4
from emokit.sensors import sensor_bits
5
6
7
def get_test_data():
8
    '''
9
    test_package.data
10
    
11
    | Sensor |   Value  | Quality  | Quality L1 | Quality L2 |
12
    +--------+----------+----------+------------+------------+
13
    |   F3   |    2     |    0     |  Nothing   |  Nothing   |
14
    |   FC5  |    81    |    0     |  Nothing   |  Nothing   |
15
    |   AF3  |   -100   |    0     |  Nothing   |  Nothing   |
16
    |   F7   |    75    |    0     |  Nothing   |  Nothing   |
17
    |   T7   |    68    |    0     |  Nothing   |  Nothing   |
18
    |   P7   |    84    |    0     |  Nothing   |  Nothing   |
19
    |   O1   |    80    |    0     |  Nothing   |  Nothing   |
20
    |   O2   |    54    |    0     |  Nothing   |  Nothing   |
21
    |   P8   |    55    |    0     |  Nothing   |  Nothing   |
22
    |   T8   |    55    |    0     |  Nothing   |  Nothing   |
23
    |   F8   |    16    |    0     |  Nothing   |  Nothing   |
24
    |   AF4  |    43    |    0     |  Nothing   |  Nothing   |
25
    |   FC6  |   128    |    0     |  Nothing   |  Nothing   |
26
    |   F4   |   1504   |    0     |  Nothing   |  Nothing   |
27
    |   X    |    21    |   N/A    |    N/A     |    N/A     |
28
    |   Y    |    22    |   N/A    |    N/A     |    N/A     |
29
    |   Z    |    ?     |   N/A    |    N/A     |    N/A     |
30
    |  Batt  |   None   |   N/A    |    N/A     |    N/A     |
31
    '''
32
    with open("test_package.data", "rb") as bin_data:
33
        data = bin_data.read()
34
        return data
35
36
37
def test_init():
38
    data = get_test_data()
39
    packet = EmotivPacket(data)
40
    for sensor in sensor_bits.keys():
41
        assert sensor in packet.sensors.keys()
42
43
44
def test_repr():
45
    data = get_test_data()
46
    packet = EmotivPacket(data)
47
48
    # tests #214
49
    assert packet.battery == None
50
    print(packet)