2018-01-07 14:09:40 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""!
|
|
|
|
|
____ ____ ______ __ __ __ _____
|
|
|
|
|
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
|
|
|
|
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
|
|
|
|
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
|
|
|
|
|
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
|
|
|
|
|
German BOS Information Script
|
|
|
|
|
by Bastian Schroll
|
|
|
|
|
|
2018-09-09 16:34:44 +02:00
|
|
|
@file: test_Decoder.py
|
2018-01-07 14:09:40 +01:00
|
|
|
@date: 15.12.2017
|
|
|
|
|
@author: Bastian Schroll
|
2018-01-08 23:41:33 +01:00
|
|
|
@description: Unittests for BOSWatch. File must be _run as "pytest" unittest
|
2018-01-07 14:09:40 +01:00
|
|
|
"""
|
2018-01-12 07:48:27 +01:00
|
|
|
import logging
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-09-09 16:34:44 +02:00
|
|
|
from boswatch.decoder.decoder import Decoder
|
2018-01-07 14:09:40 +01:00
|
|
|
|
|
|
|
|
|
2018-01-07 21:49:08 +01:00
|
|
|
class Test_Decoder:
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Unittests for the decoder"""
|
|
|
|
|
|
2018-01-12 07:48:27 +01:00
|
|
|
def setup_method(self, method):
|
2018-09-18 06:05:24 +02:00
|
|
|
logging.debug("[TEST] %s.%s", type(self).__name__, method.__name__)
|
2018-01-12 07:48:27 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderNoData(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test a empty string"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert Decoder.decode("") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderZveiValid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test valid ZVEI"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("ZVEI1: 12345") is None
|
|
|
|
|
assert not Decoder.decode("ZVEI1: 12838") is None
|
|
|
|
|
assert not Decoder.decode("ZVEI1: 34675") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderZveiDoubleTone(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test doubleTone included ZVEI"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("ZVEI1: 6E789") is None
|
|
|
|
|
assert not Decoder.decode("ZVEI1: 975E7") is None
|
|
|
|
|
assert not Decoder.decode("ZVEI1: 2E87E") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderZveiInvalid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""Test invalid ZVEI"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert Decoder.decode("ZVEI1: 1245A") is None
|
|
|
|
|
assert Decoder.decode("ZVEI1: 1245") is None
|
|
|
|
|
assert Decoder.decode("ZVEI1: 135") is None
|
|
|
|
|
assert Decoder.decode("ZVEI1: 54") is None
|
|
|
|
|
assert Decoder.decode("ZVEI1: 54") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderPocsagValid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test valid POCSAG"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("POCSAG512: Address: 1000000 Function: 0") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG512: Address: 1000001 Function: 1") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG1200: Address: 1000002 Function: 2") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG2400: Address: 1000003 Function: 3") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderPocsagText(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test POCSAG with text"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("POCSAG512: Address: 1000000 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG512: Address: 1000001 Function: 1 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG1200: Address: 1000002 Function: 2 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG2400: Address: 1000003 Function: 3 Alpha: test") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderPocsagShortRic(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test short POCSAG"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("POCSAG512: Address: 3 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG512: Address: 33 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG1200: Address: 333 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG1200: Address: 3333 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG2400: Address: 33333 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG2400: Address: 333333 Function: 0 Alpha: test") is None
|
|
|
|
|
assert not Decoder.decode("POCSAG2400: Address: 3333333 Function: 0 Alpha: test") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderPocsagInvalid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test invalid POCSAG"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert Decoder.decode("POCSAG512: Address: 333333F Function: 0 Alpha: invalid") is None
|
|
|
|
|
assert Decoder.decode("POCSAG512: Address: 333333F Function: 1 Alpha: invalid") is None
|
|
|
|
|
assert Decoder.decode("POCSAG512: Address: 3333333 Function: 4 Alpha: invalid") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderFmsValid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test valid FMS"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct""") is None
|
|
|
|
|
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct""") is None
|
|
|
|
|
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct""") is None
|
|
|
|
|
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct""") is None
|
|
|
|
|
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct""") is None
|
2018-01-07 14:09:40 +01:00
|
|
|
|
2018-01-11 12:59:53 +01:00
|
|
|
def test_decoderFmsInvalid(self):
|
2018-01-07 14:09:40 +01:00
|
|
|
"""!Test invalid FMS"""
|
2018-09-09 16:34:44 +02:00
|
|
|
assert Decoder.decode("""FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct""") is None
|
|
|
|
|
assert Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Sta 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct""") is None
|
|
|
|
|
assert Decoder.decode("""FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC incorrect""") is None
|
|
|
|
|
assert Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Sta 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC incorrect""") is None
|