def run_test_data(test_data_id: str, **kwargs) -> Response: test_data: TestData = kwargs[test_data_id] if test_data.seg_name not in segments: return error_response(400, 'Error in segment name') tpf_server = TpfServer() test_data = tpf_server.run(test_data.seg_name, test_data) return jsonify(test_data.cascade_to_dict())
class RealTimeMacro(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_reg_pointers(2) self.test_data.add_all_regs() self.test_data.add_fields(['EBT000', 'EBW000', ('EBX000', 4)], 'EB0EB') def test_ts17(self): test_data = self.tpf_server.run('TS17', self.test_data) self.assertEqual('C100', test_data.output.reg_pointers['R1']) self.assertEqual('C200', test_data.output.reg_pointers['R2']) self.assertEqual('C300', test_data.output.reg_pointers['R3']) self.assertEqual('C4C4', test_data.output.reg_pointers['R4']) self.assertListEqual(['021014', '19000'], test_data.output.dumps) self.assertIn("MAXIMUM NUMBER OF NAMES PER PNR IS 99 - CREATE NEW PNR", test_data.output.messages) # self.assertEqual(self.tpf_server.heap['TS17PDWK'], self.tpf_server.regs.get_value('R4')) self.assertNotIn('TS17PDWK', self.tpf_server.heap['new']) self.assertEqual(1, len(self.tpf_server.detac_stack['2'])) self.assertEqual(0, len(self.tpf_server.detac_stack['1'])) self.assertEqual(20, test_data.output.regs['R5']) def test_segment_call(self): # Flow is TS10 <-> TS01 -> TS02 -< TS10 => TS13 test_data = self.tpf_server.run('TS10', self.test_data) # Check if OI EBT000,1 is executed (Proof of execution of TS01) self.assertEqual('01', test_data.get_field('EBT000')) # Check if BCTR R5,0 is executed (Proof of execution of TS02) self.assertEqual(-1, test_data.output.regs['R5']) # Check if MVC EBW000,EBT000 is executed (Proof of execution of TS13) self.assertEqual('01', test_data.get_field('EBW000')) # Check PNAMC self.assertEqual('E3E2F1F0', test_data.get_field('EBX000'))
class PdredNames(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() def test_multiple_names(self): self.test_data.add_pnr_element(['C/21TOURS', '2ZAVERI', 'I/2ZAVERI/S'], 'name') test_data = self.tpf_server.run('TS18', self.test_data) self.assertEqual(list(), test_data.output.messages) self.assertEqual(25, test_data.output.regs['R1']) def test_multiple_corporate(self): self.test_data.add_pnr_element( ['C/21TOURS', '2ZAVERI', 'I/2ZAVERI/S', 'C/21VEENA TOURS'], 'name') test_data = self.tpf_server.run('TS18', self.test_data) self.assertIn("MORE THAN 1 C/", test_data.output.messages) self.assertEqual(0, test_data.output.regs['R1']) def test_100_names(self): # Check for > 99 names self.test_data.add_pnr_element(['55ZAVERI', '45SHAH'], 'name') test_data = self.tpf_server.run('TS18', self.test_data) self.assertIn("MORE THAN 99 NAMES", test_data.output.messages) self.assertEqual(100, test_data.output.regs['R1'])
class Ts23Test(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBW000', 28), 'CE1$UID'], 'EB0EB') self.test_data.add_fields(['@HAALC'], 'GLOBAL') self.test_data.add_all_regs() def test_ts23(self): test_data = self.tpf_server.run('TS23', self.test_data) self.assertEqual( '00000001000000020000000300000004000000050000000600000007', test_data.get_field('EBW000')) self.assertEqual('E5E7', test_data.get_field('@HAALC')) self.assertEqual('44', test_data.get_field('CE1$UID')) self.assertEqual(1, test_data.output.regs['R11']) self.assertEqual(1, test_data.output.regs['R12']) self.assertEqual(2, test_data.output.regs['R13']) def test_prima_1f(self): self.test_data.set_field('WA0PHA', bytes([0x02])) test_data = self.tpf_server.run('TS23', self.test_data) self.assertEqual(4, test_data.output.regs['R11']) def test_prima_1b(self): self.test_data.set_field('WA0PHA', bytes([0x03])) test_data = self.tpf_server.run('TS23', self.test_data) self.assertEqual(5, test_data.output.regs['R11']) def test_mcpck(self): self.test_data.partition = 'LA' test_data = self.tpf_server.run('TS23', self.test_data) self.assertEqual(2, test_data.output.regs['R12'])
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() ecb_fields = ["EBW015", "EBW016", "EBW010", "EBW011", "EBW012", "EBW013", ("EBW020", 4), ("EBW024", 4)] self.test_data.add_fields(ecb_fields, "EB0EB") self.test_data.output.debug = ["TS16"]
class Conditional(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() ecb_fields = ["EBW015", "EBW016", "EBW010", "EBW011", "EBW012", "EBW013", ("EBW020", 4), ("EBW024", 4)] self.test_data.add_fields(ecb_fields, "EB0EB") self.test_data.output.debug = ["TS16"] def test_ts16_1(self): # Default state is 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1.1, 7.2.1, 7.3.1, 7.4.1 test_data = self.tpf_server.run("TS16", self.test_data) self.assertEqual(1, test_data.output.regs["R0"]) self.assertEqual(2, test_data.output.regs["R1"]) self.assertEqual(1, test_data.output.regs["R2"]) self.assertEqual(1, test_data.output.regs["R3"]) self.assertEqual(1, test_data.output.regs["R4"]) self.assertEqual(1, test_data.output.regs["R5"]) self.assertEqual("C2C2C200", test_data.get_field("EBW020")) self.assertEqual(0x32, test_data.output.regs["R7"]) self.assertEqual("0000123C", test_data.get_field("EBW024")) self.assertEqual("10", test_data.get_field("EBW015")) self.assertEqual("02", test_data.get_field("EBW016")) # Test subroutines self.assertEqual("0A", test_data.get_field("EBW010")) self.assertEqual("00", test_data.get_field("EBW011")) self.assertEqual("0C", test_data.get_field("EBW012")) self.assertEqual("0D", test_data.get_field("EBW013")) def test_ts16_2(self): # Update state to 1.2, 2.2, 3.2, 4.2, 5.2, 7.1.2, 7.2.2, 7.3.2, 7.4.2 self.test_data.set_field("EBW000", bytearray([0xC1, 0xC2, 0xC3, 0xC4])) self.test_data.set_field("EBW004", bytearray([0xC1, 0xC2, 0xC3, 0xC5])) self.test_data.set_field("EBW008", bytearray([0xC1])) self.test_data.set_field("EBW009", bytearray([0x11])) self.test_data.regs["R15"] = -10 self.test_data.regs["R14"] = 23 test_data = self.tpf_server.run("TS16", self.test_data) self.assertEqual(2, test_data.output.regs["R0"]) self.assertEqual(3, test_data.output.regs["R1"]) self.assertEqual(2, test_data.output.regs["R2"]) self.assertEqual(1, test_data.output.regs["R3"]) self.assertEqual(2, test_data.output.regs["R4"]) self.assertEqual(2, test_data.output.regs["R5"]) self.assertEqual("0B", test_data.get_field("EBW011")) self.assertEqual("C2C2C2C2", test_data.get_field("EBW020")) self.assertEqual(0x33, test_data.output.regs["R7"]) self.assertEqual("0001234C", test_data.get_field("EBW024")) self.assertEqual("0F", test_data.get_field("EBW015")) self.assertEqual("03", test_data.get_field("EBW016")) def test_ts16_3(self) -> None: # Update state to 3.3, 5.3 self.test_data.regs["R15"] = 10 self.test_data.set_field("EBW009", bytearray([0x10])) test_data = self.tpf_server.run("TS16", self.test_data) self.assertEqual(3, test_data.output.regs["R2"]) self.assertEqual(2, test_data.output.regs["R3"]) self.assertEqual(3, test_data.output.regs["R5"])
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBW000', 3), 'EBW003', ('EBW004', 4), ('EBW008', 8), 'EBW020', ('EBW028', 4), ('EBW032', 4), ('EBW036', 4), ('EBW040', 4), ('EBW044', 4), ('EBW024', 4), ('EBW048', 3), ('EBW051', 7), 'EBW058'], 'EB0EB')
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() ecb_fields = [('EBW000', 4), ('EBW004', 2), ('EBW008', 12), ('EBW020', 12), ('EBW032', 6), ('EBW040', 8), ('EBW048', 8), ('EBW056', 8), ('EBW064', 6), ('EBT000', 4)] self.test_data.add_fields(ecb_fields, 'EB0EB') self.test_data.add_all_regs()
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() aaa_fields = [("WA0BBR", 2), ("WA0QHR", 6), "WA0TKK", "WA0TY1"] self.test_data.add_fields(aaa_fields, "WA0AA") ecb_fields = [("EBW001", 6), ("EBW008", 6), "EBW000", "EBW016", "EBW017", "EBW018", ("EBX000", 4), ("EBX004", 4), ("EBX008", 4), ("EBX012", 4), ("EBX016", 4)] self.test_data.add_fields(ecb_fields, "EB0EB")
class NonConditional2(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() ecb_fields = [('EBW000', 4), ('EBW004', 2), ('EBW008', 12), ('EBW020', 12), ('EBW032', 6), ('EBW040', 8), ('EBW048', 8), ('EBW056', 8), ('EBW064', 6), ('EBT000', 4)] self.test_data.add_fields(ecb_fields, 'EB0EB') self.test_data.add_all_regs() def test_ts15(self): test_data = self.tpf_server.run('TS15', self.test_data) self.assertEqual(23, test_data.output.regs['R2']) self.assertEqual('00000017', test_data.get_field('EBW000')) self.assertEqual(-2, test_data.output.regs['R3']) self.assertEqual('FF00', test_data.get_field('EBW004')) self.assertEqual(0x40404040, test_data.output.regs['R15']) self.assertEqual(0xC1404040, test_data.get_unsigned_value('R0')) self.assertEqual(0x40C14040, test_data.output.regs['R1']) self.assertEqual('40404040C140404040C14040', test_data.get_field('EBW008')) self.assertEqual('40404040C140404040C14040', test_data.get_field('EBW020')) self.assertEqual('000000000002048C', test_data.get_field('EBW040')) self.assertEqual(2048, test_data.output.regs['R4']) self.assertEqual('000000000012048C', test_data.get_field('EBW048')) self.assertEqual(12048, test_data.output.regs['R5']) self.assertEqual(14096, test_data.output.regs['R6']) self.assertEqual('000000000014096C', test_data.get_field('EBW056')) self.assertEqual('F0F1F4F0F9C6', test_data.get_field('EBW032')) self.assertEqual('F0F1F4F0F9F6', test_data.get_field('EBW064')) self.assertEqual(4, test_data.output.regs['R7']) self.assertEqual(2, test_data.output.regs['R12']) self.assertEqual('F0F2F0F4', test_data.get_field('EBT000'))
class Ts26Test(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() def test_ts26(self): test_data = self.tpf_server.run("TS26", self.test_data) self.assertIn("EXECUTION ERROR", test_data.output.messages) self.assertIn("000003", test_data.output.dumps) self.assertEqual("$$TS26$$.1", test_data.output.last_line)
class DbTest(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields(['EBW000'], 'EB0EB') self.test_data.add_all_regs() def test_tpfdf_ts20(self): self.test_data.add_tpfdf(tr1gaa, '40', 'TR1GAA') test_data = self.tpf_server.run('TS20', self.test_data) self.assertEqual(21, test_data.output.regs['R0']) self.assertEqual('80', test_data.get_field('EBW000'))
class NonConditional1(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() aaa_fields = [("WA0BBR", 2), ("WA0QHR", 6), "WA0TKK", "WA0TY1"] self.test_data.add_fields(aaa_fields, "WA0AA") ecb_fields = [("EBW001", 6), ("EBW008", 6), "EBW000", "EBW016", "EBW017", "EBW018", ("EBX000", 4), ("EBX004", 4), ("EBX008", 4), ("EBX012", 4), ("EBX016", 4)] self.test_data.add_fields(ecb_fields, "EB0EB") def test_ts14(self): test_data = self.tpf_server.run("TS14", self.test_data) aaa = config.AAA self.assertEqual(0xFFFFC1C1, test_data.get_unsigned_value("R2")) self.assertEqual("C1C1", test_data.get_field("WA0BBR")) self.assertEqual("00000000C1C1", test_data.get_field("WA0QHR")) self.assertEqual(2, test_data.output.regs["R3"]) self.assertEqual("02", test_data.get_field("WA0TKK")) self.assertEqual(2, test_data.output.regs["R5"]) self.assertEqual(-2, test_data.output.regs["R6"]) self.assertEqual(4, test_data.output.regs["R7"]) self.assertEqual(2, test_data.output.regs["R10"]) self.assertEqual(0x00000100, test_data.output.regs["R4"]) self.assertEqual(0x00000000, test_data.output.regs["R11"]) self.assertEqual(-1, test_data.output.regs["R12"]) self.assertEqual(config.AAA + macros["WA0AA"].evaluate("WA0TKK"), test_data.output.regs["R13"]) self.assertEqual(config.AAA + macros["WA0AA"].evaluate("WA0DAR") + 1, test_data.output.regs["R14"]) self.assertEqual(5, test_data.output.regs["R15"]) self.assertEqual("02", test_data.get_field("EBW000")) self.assertEqual("40" * 6, test_data.get_field("EBW001")) self.assertEqual("00" * 6, test_data.get_field("EBW008")) self.assertTrue(self.tpf_server.vm.is_updated(config.ECB + 16, 6)) self.assertFalse(self.tpf_server.vm.is_updated(config.ECB + 15, 1)) self.assertEqual("42", test_data.get_field("EBW016")) self.assertEqual("40", test_data.get_field("EBW017")) self.assertEqual(f"{macros['WA0AA'].evaluate('#WA0GEN'):02X}", test_data.get_field("WA0TY1")) self.assertTrue(self.tpf_server.vm.is_updated_bit(aaa + 0x030, 0x80)) self.assertFalse(self.tpf_server.vm.is_updated_bit(aaa + 0x030, 0x40)) self.assertEqual(f"{0xFF - macros['WA0AA'].evaluate('#WA0GEN'):02X}", test_data.get_field("EBW018")) self.assertEqual(272, test_data.output.regs["R0"]) self.assertEqual(5, int(test_data.get_field("EBX000"), 16)) self.assertEqual(3, int(test_data.get_field("EBX004"), 16)) self.assertEqual(0, int(test_data.get_field("EBX008"), 16)) self.assertEqual(6144, int(test_data.get_field("EBX012"), 16)) self.assertEqual(100, int(test_data.get_field("EBX016"), 16))
class Wgu4Test(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs() def test_wgu4_new_wgul_path(self): self.test_data.add_pnr_element(['1ZAVERI/NAYAN'], 'name') self.test_data.set_field('MH1BT11', bytes([0x01])) self.test_data.set_field('MI0ACC', DataType('C', input='FFAAC416M24').to_bytes()) test_data = self.tpf_server.run('TS24', self.test_data) self.assertEqual('TS24EXIT.1', test_data.output.last_line) self.assertEqual(list(), test_data.output.messages) self.assertEqual(0, test_data.output.regs['R0']) def test_wgu4_old_path(self): self.test_data.add_pnr_element(['1ZAVERI/NAYAN'], 'name') self.test_data.set_field('MI0ACC', DataType('C', input='FFAAC416M24').to_bytes()) test_data = self.tpf_server.run('TS24', self.test_data) self.assertEqual('TS24EXIT.1', test_data.output.last_line) self.assertEqual(list(), test_data.output.messages) self.assertEqual(-2, test_data.output.regs['R0'])
def test_segment(self): self.maxDiff = None seg: Segment = segments[self.SEG_NAME] lines = Line.from_file(File.open(segments[self.SEG_NAME].file_name)) instructions = [ line.command for line in lines if line.command not in macros ] unknown_in_assembly = { command for command in instructions if command not in seg.all_commands } self.assertSetEqual(set(), unknown_in_assembly, "\nUnknown in assembly.") seg.assemble() unknown_in_execute = { node.command for _, node in seg.nodes.items() if node.command not in TpfServer()._ex } self.assertSetEqual(set(), unknown_in_execute, "\nUnknown in execute.")
def setUpClass(cls) -> None: cls.tpf_server = TpfServer()
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields(['EBW000'], 'EB0EB') self.test_data.add_all_regs()
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBW000', 28), 'CE1$UID'], 'EB0EB') self.test_data.add_fields(['@HAALC'], 'GLOBAL') self.test_data.add_all_regs()
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.output.debug = self.SEGMENTS if config.TEST_DEBUG else list( ) self.output = None
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_regs()
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_all_reg_pointers(2) self.test_data.add_all_regs() self.test_data.add_fields(['EBT000', 'EBW000', ('EBX000', 4)], 'EB0EB')
class Sub1Test(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBX000', 3), ('EBX003', 5), ('EBX008', 3)], 'EB0EB') self.test_data.output.regs['R0'] = 0 def test_b4t0(self): self.test_data.set_field('EBX003', DataType('C', input='B4T0').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'B4T0 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('C2F4E3', test_data.get_field('EBX000')) self.assertEqual('00017F', test_data.get_field('EBX008')) # TODO remove once the scenario for it is present tnaa_bytes = DataType( 'X', input='00003EF8000002A40000001A00040000').to_bytes() self.assertEqual(tnaa_bytes, segments['SUB1'].get_constant_bytes('SUB2TNAA', 16)) def test_00017F(self): self.test_data.set_field('EBX008', DataType('X', input='00017F').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'B4T0 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('C2F4E3', test_data.get_field('EBX000')) self.assertEqual('00017F', test_data.get_field('EBX008')) def test_b4t1(self): self.test_data.set_field('EBX003', DataType('C', input='B4T1').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'B4T1 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('006F2F', test_data.get_field('EBX000')) self.assertEqual('006F2F', test_data.get_field('EBX008')) def test_006F2F_encode(self): self.test_data.set_field('EBX000', DataType('X', input='006F2F').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'B4T1 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('006F2F', test_data.get_field('EBX000')) self.assertEqual('006F2F', test_data.get_field('EBX008')) def test_A0B_encode(self): self.test_data.set_field('EBX000', DataType('C', input='A0B').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'A0B0 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('C1F0C2', test_data.get_field('EBX000')) self.assertEqual('000001', test_data.get_field('EBX008')) def test_000001(self): self.test_data.set_field('EBX008', DataType('X', input='000001').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'A0B0 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('C1F0C2', test_data.get_field('EBX000')) self.assertEqual('000001', test_data.get_field('EBX008')) def test_A1B1(self): self.test_data.set_field('EBX003', DataType('C', input='A1B1').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'A1B1 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('006DCB', test_data.get_field('EBX000')) self.assertEqual('006DCB', test_data.get_field('EBX008')) def test_006DCB(self): self.test_data.set_field('EBX008', DataType('X', input='006DCB').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'A1B1 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('006DCB', test_data.get_field('EBX000')) self.assertEqual('006DCB', test_data.get_field('EBX008')) def test_DP83(self): self.test_data.set_field('EBX003', DataType('C', input='DP83').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'DP83 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('01714A', test_data.get_field('EBX000')) self.assertEqual('01714A', test_data.get_field('EBX008')) def test_01714A(self): self.test_data.set_field('EBX008', DataType('X', input='01714A').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( 'DP83 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('01714A', test_data.get_field('EBX000')) self.assertEqual('01714A', test_data.get_field('EBX008')) def test_2Z3T(self): self.test_data.set_field('EBX003', DataType('C', input='2Z3T').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(3, test_data.output.regs['R0']) def test_23Y7(self): self.test_data.set_field('EBX003', DataType('C', input='23Y7').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( '23Y7 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('0365C6', test_data.get_field('EBX000')) self.assertEqual('0365C6', test_data.get_field('EBX008')) def test_0365C6(self): self.test_data.set_field('EBX008', DataType('X', input='0365C6').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( '23Y7 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('0365C6', test_data.get_field('EBX000')) self.assertEqual('0365C6', test_data.get_field('EBX008')) def test_4K37(self): self.test_data.set_field('EBX003', DataType('C', input='4K37').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( '4K37 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('035DA7', test_data.get_field('EBX000')) self.assertEqual('035DA7', test_data.get_field('EBX008')) def test_035DA7(self): self.test_data.set_field('EBX008', DataType('X', input='035DA7').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) self.assertEqual( '4K37 ', DataType('X', input=test_data.get_field('EBX003')).decode) self.assertEqual('035DA7', test_data.get_field('EBX000')) self.assertEqual('035DA7', test_data.get_field('EBX008')) def test_C4C6E6_encode(self): self.test_data.set_field('EBX000', DataType('X', input='C4C6E6').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) def test_F1F2F3_encode(self): self.test_data.set_field('EBX000', DataType('X', input='F1F2F3').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) def test_DFW(self): self.test_data.set_field('EBX003', DataType('C', input='DFW').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) def test_123(self): self.test_data.set_field('EBX003', DataType('C', input='123').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(0, test_data.output.regs['R0']) def test_error_code_1(self): test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(1, test_data.output.regs['R0']) def test_error_code_3(self): self.test_data.set_field('EBX003', DataType('C', input='-*A').to_bytes()) test_data = self.tpf_server.run('TS22', self.test_data) self.assertEqual('TS22EXIT.1', test_data.output.last_line) self.assertEqual(3, test_data.output.regs['R0']) def tearDown(self) -> None: pass
def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBX000', 3), ('EBX003', 5), ('EBX008', 3)], 'EB0EB') self.test_data.output.regs['R0'] = 0
class Ts25Test(unittest.TestCase): def setUp(self) -> None: self.tpf_server = TpfServer() self.test_data = TestDataUTS() self.test_data.add_fields([('EBW000', 3), 'EBW003', ('EBW004', 4), ('EBW008', 8), 'EBW020', ('EBW028', 4), ('EBW032', 4), ('EBW036', 4), ('EBW040', 4), ('EBW044', 4), ('EBW024', 4), ('EBW048', 3), ('EBW051', 7), 'EBW058'], 'EB0EB') def test_ts25(self): test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('00789C', test_data.get_field('EBW000')) self.assertEqual('01', test_data.get_field('EBW003')) self.assertEqual('0000000C', test_data.get_field('EBW004')) self.assertEqual('000000000000053C', test_data.get_field('EBW008')) # Decimal Arithmatic self.assertEqual('0000093D', test_data.get_field('EBW028')) self.assertEqual('0000186D', test_data.get_field('EBW032')) self.assertEqual('0000225D', test_data.get_field('EBW036')) self.assertEqual('0000132D', test_data.get_field('EBW040')) self.assertEqual('0005148C', test_data.get_field('EBW044')) self.assertEqual('132D000C', test_data.get_field('EBW024')) # TR self.assertEqual('C4C1C7', test_data.get_field('EBW048')) self.assertEqual('FFFF440000FFFF', test_data.get_field('EBW051')) def test_tp_valid(self): self.test_data.set_field('EBW016', bytes([0x00, 0x12, 0x34, 0x5C])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('F0', test_data.get_field('EBW020')) def test_tp_sign_invalid(self): self.test_data.set_field('EBW016', bytes([0x00, 0x12, 0x34, 0x59])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('F1', test_data.get_field('EBW020')) def test_tp_digit_invalid(self): self.test_data.set_field('EBW016', bytes([0x00, 0x12, 0x3A, 0x5C])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('F2', test_data.get_field('EBW020')) def test_tp_sign_invalid_and_digit_invalid(self): self.test_data.set_field('EBW016', bytes([0x00, 0x12, 0x3A, 0x59])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('F3', test_data.get_field('EBW020')) def test_tr_with_7(self): self.test_data.set_field('EBW058', bytes([0xF7])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('07', test_data.get_field('EBW058')) def test_tr_with_F(self): self.test_data.set_field('EBW058', bytes([0xC6])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('15', test_data.get_field('EBW058')) def test_tr_with_U(self): self.test_data.set_field('EBW058', bytes([0xE4])) test_data = self.tpf_server.run('TS25', self.test_data) self.assertEqual('30', test_data.get_field('EBW058'))