FreeDATA/tests/test_data_frame_factory.py

48 lines
1.6 KiB
Python
Raw Normal View History

2023-11-27 18:22:16 +00:00
import sys
sys.path.append('modem')
import unittest
from config import CONFIG
import data_frame_factory
2023-11-27 22:08:00 +00:00
import helpers
2023-11-27 18:22:16 +00:00
class TestDataFrameFactory(unittest.TestCase):
@classmethod
def setUpClass(cls):
config_manager = CONFIG('modem/config.ini.example')
config = config_manager.read()
cls.factory = data_frame_factory.DataFrameFactory(config)
def testBeacon(self):
beacon_frame = self.factory.build_beacon()
beacon_data = self.factory.deconstruct(beacon_frame)
2023-11-29 16:39:35 +00:00
self.assertEqual(beacon_data['origin'], self.factory.myfullcall.upper())
2023-11-27 22:08:00 +00:00
self.assertEqual(beacon_data['gridsquare'], self.factory.mygrid.upper())
2023-11-27 18:22:16 +00:00
def testPing(self):
dxcall = "DJ2LS-3"
ping_frame = self.factory.build_ping(dxcall)
ping_data = self.factory.deconstruct(ping_frame)
2023-11-29 16:39:35 +00:00
self.assertEqual(ping_data['origin'], self.factory.myfullcall)
self.assertEqual(ping_data['destination_crc'], helpers.get_crc_24(dxcall))
2023-11-27 22:08:00 +00:00
def testARQConnectWide(self):
dxcall = "DJ2LS-4"
session_id = 123
frame = self.factory.build_arq_connect(True, dxcall, session_id)
frame_data = self.factory.deconstruct(frame)
2023-11-29 16:39:35 +00:00
self.assertEqual(frame_data['origin'], self.factory.myfullcall)
2023-11-27 22:08:00 +00:00
2023-12-05 18:01:48 +00:00
self.assertEqual(frame_data['session_id'] , session_id)
2023-11-27 18:22:16 +00:00
2023-11-29 16:42:44 +00:00
def testCQ(self):
frame = self.factory.build_cq()
frame_data = self.factory.deconstruct(frame)
self.assertEqual(frame_data['origin'], self.factory.myfullcall)
self.assertEqual(frame_data['gridsquare'], self.factory.mygrid.upper())
2023-11-29 16:39:35 +00:00
2023-11-27 18:22:16 +00:00
if __name__ == '__main__':
unittest.main()