Add unit tests for ADPU class

henryk_github
Henryk Plötz 12 years ago
parent 9d5528a470
commit 06a899f8e6
  1. 1
      tests/__init__.py
  2. 5
      tests/__main__.py
  3. 38
      tests/utilstest.py

@ -0,0 +1 @@
from utilstest import *

@ -0,0 +1,5 @@
import unittest
from tests import *
if __name__ == "__main__":
unittest.main()

@ -0,0 +1,38 @@
"""Unit test for utils.py"""
import utils
import unittest
class APDUCase1Tests(unittest.TestCase):
def setUp(self):
self.a4 = utils.C_APDU("\x00\xa4\x00\x00")
def tearDown(self):
del self.a4
def testCreation(self):
self.assertEqual(0, self.a4.CLA)
self.assertEqual(0xa4, self.a4.INS)
self.assertEqual(0, self.a4.P1)
self.assertEqual(0, self.a4.P2)
def testRender(self):
self.assertEqual("\x00\xa4\x00\x00", self.a4.render())
def testCopy(self):
b0 = utils.C_APDU(self.a4, INS=0xb0)
self.assertEqual("\x00\xb0\x00\x00", b0.render())
def testAssign(self):
self.a4.p2 = 5
self.assertEqual(5, self.a4.P2)
self.assertEqual("\x00\xa4\x00\x05", self.a4.render())
def testCreateSequence(self):
a4_2 = utils.C_APDU(0, 0xa4, 0, 0)
self.assertEqual(self.a4.render(), a4_2.render())
Loading…
Cancel
Save