Extend unit test coverage for construct, add [some] tests for TLV

Change-Id: I3470e0b2e978221aa0c1e46a4b65f71f71abef2e
This commit is contained in:
Harald Welte
2022-02-12 10:31:27 +01:00
parent d0519e0c37
commit 81f4b4058b
2 changed files with 132 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import unittest
from pySim.construct import GreedyInteger
from pySim.construct import *
tests = [
( b'\x80', 0x80 ),
@@ -21,6 +21,17 @@ class TestGreedyInt(unittest.TestCase):
self.assertEqual(t[0], gi.build(t[1]))
pass
class TestUtils(unittest.TestCase):
def test_filter_dict(self):
inp = {'foo': 0xf00, '_bar' : 0xba5, 'baz': 0xba2 }
out = {'foo': 0xf00, 'baz': 0xba2 }
self.assertEqual(filter_dict(inp), out)
def test_filter_dict_nested(self):
inp = {'foo': 0xf00, 'nest': {'_bar' : 0xba5}, 'baz': 0xba2 }
out = {'foo': 0xf00, 'nest': {}, 'baz': 0xba2 }
self.assertEqual(filter_dict(inp), out)
if __name__ == "__main__":
unittest.main()