From 6d39e1553252a07209d4aff6bb467f2ebc061fe0 Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Sat, 10 Oct 2020 15:39:34 +0200 Subject: [PATCH] Add simple_trie fixture and blackbox tests --- .drone.yml | 3 +- tests/conftest.py | 5 ++++ tests/test_bytetrie_blackbox.py | 49 ++++++++++++++++++++++++++++++++ tests/tries/simple_trie.png | Bin 0 -> 21537 bytes tests/tries/simple_trie.py | 28 ++++++++++++++++++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 tests/conftest.py create mode 100644 tests/test_bytetrie_blackbox.py create mode 100644 tests/tries/simple_trie.png create mode 100644 tests/tries/simple_trie.py diff --git a/.drone.yml b/.drone.yml index 50b299b..920f110 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,8 +7,7 @@ steps: image: python:3 commands: - pip install mypy pytest - - mypy bytetrie/bytetrie.py - - mypy bytetrie/util.py + - mypy bytetrie/*.py - python -m pytest - name: publish diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..aae94a5 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +import pytest + +pytest_plugins = [ + "tries.simple_trie" +] diff --git a/tests/test_bytetrie_blackbox.py b/tests/test_bytetrie_blackbox.py new file mode 100644 index 0000000..19f84a8 --- /dev/null +++ b/tests/test_bytetrie_blackbox.py @@ -0,0 +1,49 @@ +import pytest + +import sys +import os +sys.path.append("tests/tries/") + +from bytetrie import ByteTrie + +import simple_trie + +def test_find_all(simple_trie): + r = simple_trie.find(b"A") + ls = [n.value() for n in r] + expected = ["A", "AA", "AACDEGG", "AACDEF", "AACDEH", "AB", "ABCDE"] + not_expected = ["AACDE"] + + for e in expected: + assert e in ls + for ne in not_expected: + assert not ne in ls + +def test_find_single_terminal(simple_trie): + r = simple_trie.find(b"AACDEH") + assert len(r) == 1 + assert r[0].value() == "AACDEH" + assert r[0].key() == b"AACDEH" + +def test_unknown_prefix_empty(simple_trie): + r = simple_trie.find(b"AAD") + assert len(r) == 0 + +def test_partial_prefix_find_subnodes(simple_trie): + r = simple_trie.find(b"AACD") + ls = [n.value() for n in r] + + expected = ["AACDEGG", "AACDEF", "AACDEH"] + not_expected = ["A", "AA", "AB", "ABCDE", "AACDE"] + + assert len(r) == 3 + for e in expected: + assert e in ls + for ne in not_expected: + assert not ne in ls + +def test_partial_prefix_find_terminal(simple_trie): + r = simple_trie.find(b"ABC") + assert len(r) == 1 + assert r[0].key() == b"ABCDE" + assert r[0].value() == "ABCDE" diff --git a/tests/tries/simple_trie.png b/tests/tries/simple_trie.png new file mode 100644 index 0000000000000000000000000000000000000000..aac579d19fd76caf74ebde7dba980a23fa5a4e74 GIT binary patch literal 21537 zcmdS>WmJ~!);0{Ebax5}NJ@hsAreY=3P?+dARq{cG@^8fNQekXhkzj6NQ2UdbcuvC z2uQy3xSsbO&v%dS&-eFRYg}Wk!F8PbvB%u!+~zj7d4y|gDiPt+;iFI}A{AwMT@(t9 z1OBPU#fHB)-xgPb|G~CWQ<6trBLB^3%!@~%m{BV7cl5ndH)ft2>D!*->}-D)V98*< z&M(VSQWLc3%$;w4lKChl#cnzA-DKw9KOP0MpFTYv(&b4~R~8n#ONmLPPpYjZKTTu$ zGtMu)HXz{kqewM=;r-MHTLT{76(rgujs%70p7%=(WU{cJTSsw)g>RtKT5qI_C(~L- zw6(U=>M;mUU#$cx?0VVOD-V?(*_-enG(f zABHmSVC3s__ax8@5OWwfn%24Fb;Vq5oA~n3_2l4DsE$s!(Tb4zHi?M z`}_OtCo8y&s~+RIxVU)v_+;tjX+C-OZ2UWgWp%-EA%n0!r)H|GjSU;|)mtxLzQnY# zv-{fKj`=<1W^i@281g$35)u*nK~yx|%@<$32s1D+SlZfR>FMc>7MswZwDt8dD~+Qg zBJe3GDVZfD>91V5(%swpb-6DoE-^7g_+dY@l+;zaXlx>S(U;B5GTsNPK`kw^6^`SY zdls383zk;ca>WL$H*SzmRXNGY%VU<9)rVjc(Pb#bGOo@xN}ipc4;AQf{`~oK)#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Y3J)}ndKL#4Z|p{_ jpC+rwr#USX#mXx#eW!LU)Jj0}6XEVc__od|;P(FkXR5us literal 0 HcmV?d00001 diff --git a/tests/tries/simple_trie.py b/tests/tries/simple_trie.py new file mode 100644 index 0000000..1b48c86 --- /dev/null +++ b/tests/tries/simple_trie.py @@ -0,0 +1,28 @@ +""" +Create a simple ByteTrie fixture for testing basic functionality. Without edge +cases. Single-valued. + +See simple_trie.png +""" + +import pytest + +from bytetrie import ByteTrie + +def insert(trie): + """ Shall only be used to insert strings """ + t = trie + def _insert(*vals): + for val in vals: + t.insert(val.encode('utf-8'), val) + return _insert + +@pytest.fixture +def simple_trie(): + t = ByteTrie() + ins = insert(t) + ins("A") + ins("AA", "AB") + ins("ABCDE") + ins("AACDEF", "AACDEGG", "AACDEH") + return t