PP_glzk_emil/tests.py
2019-11-04 22:47:15 +01:00

21 lines
976 B
Python

import unittest
from pesel import PeselStorage, PeselToolkit
class TestPeselToolkit(unittest.TestCase):
def test_toolkit(self):
pesele = ["81100216357","80072909146","02070803628","90060804786" ]
for x in pesele:
self.assertTrue(PeselToolkit.check_pesel_validity(x))
invalid = ["02070803627","81100216350","80072909143","02070803624","90060804781","81950216357","80075609146","0207080362444","90060804782"]
for x in invalid:
self.assertFalse(PeselToolkit.check_pesel_validity(x))
class TestPeselStorage(unittest.TestCase):
def test_storage(self):
s = PeselStorage()
s.append("janek", "80072909146")
s.append("janek2", "02070803628")
self.assertListEqual(s.get_all_persons(), ["janek", "janek2"])
self.assertRaises(AttributeError, s.append, "zly", "02070803627")
self.assertEqual(s.get_pesel_of("janek"),"80072909146" )
if __name__=="__main__":
unittest.main()