From 84e5e03bdcc22cef60fab125381b2b716fe947a7 Mon Sep 17 00:00:00 2001 From: Kirsten Hunter Date: Thu, 22 Feb 2024 14:35:59 -0800 Subject: [PATCH] Unsupported operations --- astrapy/db.py | 67 ++++++++++++++++++++++++++++++++++++ astrapy/utils.py | 4 ++- tests/astrapy/test_db_dml.py | 7 +++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/astrapy/db.py b/astrapy/db.py index 7360e407..6523c0d0 100644 --- a/astrapy/db.py +++ b/astrapy/db.py @@ -53,6 +53,7 @@ http_methods, normalize_for_api, restore_from_api, + return_unsupported_error ) from astrapy.types import ( API_DOC, @@ -1990,6 +1991,58 @@ async def concurrent_upsert(doc: API_DOC) -> str: if isinstance(result, BaseException) and not isinstance(result, Exception): raise result return results # type: ignore + + # Mongodb calls not supported by the API + async def find_raw_batches(): + return_unsupported_error() + + async def aggregate(): + return_unsupported_error() + + async def aggregate_raw_batches(): + return_unsupported_error() + + async def watch(): + return_unsupported_error() + + async def rename(): + return_unsupported_error() + + async def create_index(): + return_unsupported_error() + + async def create_indexes(): + return_unsupported_error() + + async def drop_index(): + return_unsupported_error() + + async def drop_indexes(): + return_unsupported_error() + + async def list_indexes(): + return_unsupported_error() + + async def index_information(): + return_unsupported_error() + + async def create_search_index(): + return_unsupported_error() + + async def create_search_indexes(): + return_unsupported_error() + + async def drop_search_index(): + return_unsupported_error() + + async def list_search_indexes(): + return_unsupported_error() + + async def update_search_index(): + return_unsupported_error() + + async def distinct(): + return_unsupported_error() class AstraDB: @@ -2268,6 +2321,20 @@ def truncate_collection(self, collection_name: str) -> AstraDBCollection: # return the collection itself return collection + def aggregate(): + return_unsupported_error() + + def cursor_command(): + return_unsupported_error() + + def dereference(): + return_unsupported_error() + + def watch(): + return_unsupported_error() + + def validate_collection(): + return_unsupported_error() class AsyncAstraDB: def __init__( diff --git a/astrapy/utils.py b/astrapy/utils.py index 23c2d062..ca0c5d54 100644 --- a/astrapy/utils.py +++ b/astrapy/utils.py @@ -221,7 +221,9 @@ def make_payload(top_level: str, **kwargs: Any) -> Dict[str, Any]: return json_query - +def return_unsupported_error(): + raise Exception("Unsupported operation") + def convert_vector_to_floats(vector: Iterable[Any]) -> List[float]: """ Convert a vector of strings to a vector of floats. diff --git a/tests/astrapy/test_db_dml.py b/tests/astrapy/test_db_dml.py index 174a0ee2..f519dc22 100644 --- a/tests/astrapy/test_db_dml.py +++ b/tests/astrapy/test_db_dml.py @@ -39,7 +39,6 @@ def test_clear_collection_fail(db: AstraDB) -> None: with pytest.raises(APIRequestError): db.collection("this$does%not exist!!!").clear() - @pytest.mark.describe("should truncate a nonvector collection through AstraDB") def test_truncate_nonvector_collection_through_astradb( db: AstraDB, empty_nonv_collection: AstraDBCollection @@ -1268,6 +1267,12 @@ def test_find_find_one_non_equality_operators( ) assert resp8["data"]["documents"][0]["marker"] == "abc" +@pytest.mark.describe("test unsupported operation") +def test_unsupported_operation( + writable_v_collection: AstraDBCollection, +) -> None: + with pytest.raises(Exception): + writeable_v_collection.aggregate() @pytest.mark.describe("store and retrieve dates and datetimes correctly") def test_insert_find_with_dates(