- Update to 0.5.10:
* Translation updates in many languages OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pytricia?expand=0&rev=8
This commit is contained in:
parent
16af90c8e7
commit
ec87612e78
@ -27,11 +27,8 @@ 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
|
||||
# test file was shortened, removed testRaw and testRawIP6 for now
|
||||
# https://github.com/jsommers/pytricia/issues/26
|
||||
Source2: https://raw.githubusercontent.com/jsommers/pytricia/master/test.py
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: python-rpm-macros
|
||||
%python_subpackages
|
||||
@ -39,18 +36,14 @@ BuildRequires: python-rpm-macros
|
||||
%description
|
||||
Pytricia is a python module to store IP prefixes in a patricia tree.
|
||||
It's based on Dave Plonka's modified patricia tree code, and has three things
|
||||
to recommend it over related modules (including py-radix and SubnetTree):
|
||||
|
||||
1. it is faster
|
||||
2. it works in Python 3, and
|
||||
3. there are a few nicer library features for manipulating the structure.
|
||||
to recommend it over related modules (including py-radix and SubnetTree).
|
||||
|
||||
%prep
|
||||
%setup -q -n pytricia-%{version}
|
||||
cp %{SOURCE1} .
|
||||
cp %{SOURCE2} .
|
||||
|
||||
%build
|
||||
install -m 644 %{SOURCE1} %{_builddir}/pytricia-%{version}
|
||||
export CFLAGS="%{optflags}"
|
||||
%python_build
|
||||
|
||||
@ -58,14 +51,11 @@ export CFLAGS="%{optflags}"
|
||||
%python_install
|
||||
|
||||
%check
|
||||
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch}
|
||||
$python -m unittest discover
|
||||
}
|
||||
%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m unittest discover
|
||||
|
||||
%files %{python_files}
|
||||
%license COPYING.LESSER
|
||||
%doc README.md
|
||||
%defattr(-,root,root)
|
||||
%{python_sitearch}/*
|
||||
|
||||
%changelog
|
||||
|
40
test.py
40
test.py
@ -411,4 +411,44 @@ 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