|
1 | | -from __future__ import division, absolute_import, print_function, unicode_literals |
2 | | - |
3 | | -# coding=utf-8 |
4 | | -from unittest2 import TestCase |
5 | 1 | from emv.protocol.command import ( |
6 | 2 | CAPDU, |
7 | 3 | SelectCommand, |
|
10 | 6 | from emv.util import unformat_bytes |
11 | 7 |
|
12 | 8 |
|
13 | | -class TestCAPDU(TestCase): |
14 | | - def test_unmarshal(self): |
15 | | - pdu = CAPDU.unmarshal(unformat_bytes("00 A4 04 00 07 A0 00 00 00 03 80 02")) |
16 | | - self.assertIs(type(pdu), SelectCommand) |
17 | | - self.assertEqual(pdu.p1, 0x04) |
18 | | - self.assertEqual(pdu.p2, 0x00) |
19 | | - self.assertEqual(len(pdu.data), 0x07) |
20 | | - self.assertEqual(pdu.le, None) |
| 9 | +def test_unmarshal(): |
| 10 | + pdu = CAPDU.unmarshal(unformat_bytes("00 A4 04 00 07 A0 00 00 00 03 80 02")) |
| 11 | + assert type(pdu) is SelectCommand |
| 12 | + assert pdu.p1 == 0x04 |
| 13 | + assert pdu.p2 == 0x00 |
| 14 | + assert len(pdu.data) == 0x07 |
| 15 | + assert pdu.le is None |
21 | 16 |
|
22 | | - pdu = CAPDU.unmarshal( |
23 | | - unformat_bytes( |
24 | | - """80 AE 80 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 |
25 | | - 00 00 80 00 00 00 00 00 00 01 01 01 00 00 00 00 00""" |
26 | | - ) |
| 17 | + pdu = CAPDU.unmarshal( |
| 18 | + unformat_bytes( |
| 19 | + """80 AE 80 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 |
| 20 | + 00 00 80 00 00 00 00 00 00 01 01 01 00 00 00 00 00""" |
27 | 21 | ) |
28 | | - self.assertIs(type(pdu), GenerateApplicationCryptogramCommand) |
29 | | - self.assertEqual(pdu.p1, 0x80) |
30 | | - self.assertEqual(pdu.p2, 0x00) |
31 | | - self.assertEqual(len(pdu.data), 0x1D) |
32 | | - self.assertEqual(pdu.le, None) |
| 22 | + ) |
| 23 | + assert type(pdu) is GenerateApplicationCryptogramCommand |
| 24 | + assert pdu.p1 == 0x80 |
| 25 | + assert pdu.p2 == 0x00 |
| 26 | + assert len(pdu.data) == 0x1D |
| 27 | + assert pdu.le is None |
0 commit comments