Skip to content

Commit

Permalink
Unsupported operations
Browse files Browse the repository at this point in the history
  • Loading branch information
synedra committed Feb 22, 2024
1 parent 038c7bc commit 84e5e03
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
67 changes: 67 additions & 0 deletions astrapy/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
http_methods,
normalize_for_api,
restore_from_api,
return_unsupported_error
)
from astrapy.types import (
API_DOC,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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__(
Expand Down
4 changes: 3 additions & 1 deletion astrapy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion tests/astrapy/test_db_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 84e5e03

Please sign in to comment.