import sys sys.path.append('modem') import unittest from config import CONFIG import data_frame_factory import helpers 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) self.assertEqual(beacon_data['origin'], self.factory.myfullcall.upper()) self.assertEqual(beacon_data['gridsquare'], self.factory.mygrid.upper()) def testPing(self): dxcall = "DJ2LS-3" ping_frame = self.factory.build_ping(dxcall) ping_data = self.factory.deconstruct(ping_frame) self.assertEqual(ping_data['origin'], self.factory.myfullcall) self.assertEqual(ping_data['destination_crc'], helpers.get_crc_24(dxcall)) 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) self.assertEqual(frame_data['origin'], self.factory.myfullcall) self.assertEqual(frame_data['session_id'] , session_id) 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()) if __name__ == '__main__': unittest.main()