From 9be7072337ea4e1fec2077602af7e3c5125f8f5d Mon Sep 17 00:00:00 2001 From: aviau Date: Thu, 29 Jul 2021 18:00:59 -0400 Subject: [PATCH] index: initial sortedkv get_blob_meta + test suite --- perkeepy/index/sortedkv/__init__.py | 2 ++ perkeepy/index/sortedkv/test_sortedkv.py | 28 ++++++++++++++++++++++ perkeepy/index/test_index.py | 26 ++++++++++++++++++++ perkeepy/sortedkv/ordered_dict/__init__.py | 2 ++ 4 files changed, 58 insertions(+) create mode 100644 perkeepy/index/sortedkv/test_sortedkv.py create mode 100644 perkeepy/index/test_index.py diff --git a/perkeepy/index/sortedkv/__init__.py b/perkeepy/index/sortedkv/__init__.py index f01e025..2c246a4 100644 --- a/perkeepy/index/sortedkv/__init__.py +++ b/perkeepy/index/sortedkv/__init__.py @@ -11,3 +11,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +from .index import SortedKVIndex diff --git a/perkeepy/index/sortedkv/test_sortedkv.py b/perkeepy/index/sortedkv/test_sortedkv.py new file mode 100644 index 0000000..0134b20 --- /dev/null +++ b/perkeepy/index/sortedkv/test_sortedkv.py @@ -0,0 +1,28 @@ +# Copyright 2021 The Perkeepy Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from perkeepy.index import Indexer +from perkeepy.index import test_index +from perkeepy.index.sortedkv import SortedKVIndex +from perkeepy.sortedkv.ordered_dict import OrderedDictSortedKV + + +def test_sortedkv() -> None: + def indexer_factory() -> Indexer: + sorted_kv_indexer: Indexer = SortedKVIndex( + sorted_kv=OrderedDictSortedKV(), + ) + return sorted_kv_indexer + + test_index.run_index_test(indexer_factory=indexer_factory) diff --git a/perkeepy/index/test_index.py b/perkeepy/index/test_index.py new file mode 100644 index 0000000..40eed39 --- /dev/null +++ b/perkeepy/index/test_index.py @@ -0,0 +1,26 @@ +# Copyright 2021 The Perkeepy Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Callable + +from perkeepy.index import Indexer + + +def run_index_test(indexer_factory: Callable[[], Indexer]) -> None: + """Suite of tests to validate an Indexer implementation""" + + # Create and index a permanode + # TODO: Create a permanode using a schema builder + + assert indexer_factory diff --git a/perkeepy/sortedkv/ordered_dict/__init__.py b/perkeepy/sortedkv/ordered_dict/__init__.py index f01e025..73bdf37 100644 --- a/perkeepy/sortedkv/ordered_dict/__init__.py +++ b/perkeepy/sortedkv/ordered_dict/__init__.py @@ -11,3 +11,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +from .ordered_dict import OrderedDictSortedKV