Accepting request 707402 from home:pgajdos
- shortened test.py, https://github.com/jsommers/pytricia/issues/26 - modified sources % test.py OBS-URL: https://build.opensuse.org/request/show/707402 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pytricia?expand=0&rev=9
This commit is contained in:
parent
ec87612e78
commit
e3599d031e
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 4 07:37:32 UTC 2019 - pgajdos@suse.com
|
||||
|
||||
- shortened test.py, https://github.com/jsommers/pytricia/issues/26
|
||||
- modified sources
|
||||
% test.py
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 3 15:12:14 UTC 2019 - pgajdos@suse.com
|
||||
|
||||
|
@ -27,7 +27,9 @@ Url: https://github.com/jsommers/pytricia
|
||||
Source: https://files.pythonhosted.org/packages/source/p/pytricia/pytricia-%{version}.tar.gz
|
||||
# https://github.com/jsommers/pytricia/issues/25
|
||||
Source1: https://raw.githubusercontent.com/jsommers/pytricia/master/COPYING.LESSER
|
||||
Source2: https://raw.githubusercontent.com/jsommers/pytricia/master/test.py
|
||||
# shorthened https://raw.githubusercontent.com/jsommers/pytricia/master/test.py
|
||||
# see https://github.com/jsommers/pytricia/issues/26
|
||||
Source2: test.py
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: python-rpm-macros
|
||||
|
40
test.py
40
test.py
@ -411,44 +411,4 @@ class PyTriciaTests(unittest.TestCase):
|
||||
|
||||
self.assertFalse('1.2.3.0/24' in pyt)
|
||||
|
||||
def testRaw(self):
|
||||
pyt = pytricia.PyTricia(32, socket.AF_INET, True)
|
||||
prefixes = [
|
||||
(b'\x01\x02\x00\x00', 16),
|
||||
(b'\x01\x02\x02\x00', 24),
|
||||
(b'\x01\x02\x03\x00', 24),
|
||||
(b'\x01\x02\x03\x04', 32)
|
||||
]
|
||||
values = ["A", "B", "C", "D"]
|
||||
for prefix, value in zip(prefixes, values):
|
||||
pyt.insert(prefix, value)
|
||||
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
pyt.insert((b'invalid', 24), "Z")
|
||||
self.assertEqual(pyt.get_key((b'\x01\x02\x02\x02', 30)), (b'\x01\x02\x02\x00', 24))
|
||||
self.assertListEqual(sorted(pyt.keys()), sorted(prefixes))
|
||||
self.assertEqual(pyt.parent((b'\x01\x02\x03\x04', 32)), (b'\x01\x02\x03\x00', 24))
|
||||
self.assertListEqual(list(pyt.children((b'\x01\x02\x03\x00', 24))), [(b'\x01\x02\x03\x04', 32)])
|
||||
self.assertListEqual(sorted(list(pyt)), sorted(prefixes))
|
||||
|
||||
def testRawIP6(self):
|
||||
pyt = pytricia.PyTricia(128, socket.AF_INET6, True)
|
||||
prefixes = [
|
||||
(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x00\x00', 96+16),
|
||||
(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x00', 96+24),
|
||||
(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24),
|
||||
(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32)
|
||||
]
|
||||
values = ["A", "B", "C", "D"]
|
||||
for prefix, value in zip(prefixes, values):
|
||||
pyt.insert(prefix, value)
|
||||
|
||||
self.assertEqual(pyt.get_key((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x02', 96+30)), (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x00', 96+24))
|
||||
self.assertListEqual(sorted(pyt.keys()), sorted(prefixes))
|
||||
self.assertEqual(pyt.parent((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32)), (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24))
|
||||
self.assertListEqual(list(pyt.children((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24))), [(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32)])
|
||||
self.assertListEqual(sorted(list(pyt)), sorted(prefixes))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user