diff --git a/astrapy/idiomatic/collection.py b/astrapy/idiomatic/collection.py index f8f32dea..bb328139 100644 --- a/astrapy/idiomatic/collection.py +++ b/astrapy/idiomatic/collection.py @@ -216,6 +216,9 @@ def delete_many( f"(gotten '${json.dumps(dm_response)}')" ) + def drop(self, name_or_collection: Union[str, AsyncCollection]) -> None: + return self._astra_db_collection.astra_db.delete_collection(name_or_collection) + @unsupported def find_raw_batches(*pargs: Any, **kwargs: Any) -> Any: ... @@ -445,6 +448,10 @@ async def delete_many( f"(gotten '${json.dumps(dm_response)}')" ) + async def drop(self, name_or_collection: Union[str, AsyncCollection]) -> None: + return await self._astra_db_collection.astra_db.delete_collection(name_or_collection) + + @unsupported async def find_raw_batches(*pargs: Any, **kwargs: Any) -> Any: ... diff --git a/tests/idiomatic/conftest.py b/tests/idiomatic/conftest.py index cf5b4e68..2af01775 100644 --- a/tests/idiomatic/conftest.py +++ b/tests/idiomatic/conftest.py @@ -9,6 +9,7 @@ TEST_COLLECTION_INSTANCE_NAME = "test_coll_instance" TEST_COLLECTION_NAME = "id_test_collection" +TEST_CREATE_DELETE_VECTOR_COLLECTION_NAME = "ephemeral_v_col" ASTRA_DB_SECONDARY_KEYSPACE = os.environ.get("ASTRA_DB_SECONDARY_KEYSPACE") diff --git a/tests/idiomatic/integration/test_collections_async.py b/tests/idiomatic/integration/test_collections_async.py index 8fb05961..f2ae3881 100644 --- a/tests/idiomatic/integration/test_collections_async.py +++ b/tests/idiomatic/integration/test_collections_async.py @@ -16,7 +16,6 @@ from astrapy import AsyncCollection, AsyncDatabase - class TestCollectionsAsync: @pytest.mark.describe("test of instantiating Collection, async") async def test_instantiate_collection_async( diff --git a/tests/idiomatic/integration/test_ddl_async.py b/tests/idiomatic/integration/test_ddl_async.py index d053f652..77433d4b 100644 --- a/tests/idiomatic/integration/test_ddl_async.py +++ b/tests/idiomatic/integration/test_ddl_async.py @@ -14,7 +14,7 @@ import pytest -from ..conftest import ASTRA_DB_SECONDARY_KEYSPACE, TEST_COLLECTION_NAME +from ..conftest import ASTRA_DB_SECONDARY_KEYSPACE, TEST_COLLECTION_NAME, TEST_CREATE_DELETE_VECTOR_COLLECTION_NAME from astrapy import AsyncCollection, AsyncDatabase @@ -35,6 +35,7 @@ async def test_collection_lifecycle_async( assert col1 == col2 await async_database.drop_collection(TEST_LOCAL_COLLECTION_NAME) + @pytest.mark.describe("test of Database list_collections, async") async def test_database_list_collections_async( self, diff --git a/tests/idiomatic/integration/test_ddl_sync.py b/tests/idiomatic/integration/test_ddl_sync.py index 3f7d60ca..d9377b5f 100644 --- a/tests/idiomatic/integration/test_ddl_sync.py +++ b/tests/idiomatic/integration/test_ddl_sync.py @@ -14,10 +14,9 @@ import pytest -from ..conftest import ASTRA_DB_SECONDARY_KEYSPACE, TEST_COLLECTION_NAME +from ..conftest import ASTRA_DB_SECONDARY_KEYSPACE, TEST_COLLECTION_NAME, TEST_CREATE_DELETE_VECTOR_COLLECTION_NAME from astrapy import Collection, Database - class TestDDLSync: @pytest.mark.describe("test of collection creation, get, and then drop, sync") def test_collection_lifecycle_sync( @@ -35,6 +34,18 @@ def test_collection_lifecycle_sync( assert col1 == col2 sync_database.drop_collection(TEST_LOCAL_COLLECTION_NAME) + @pytest.mark.describe("should create and destroy a vector collection using collection drop ") + def test_create_destroy_collection(self, sync_database: Database) -> None: + col = sync_database.create_collection( + name="TEST_CREATE_DELETE_VECTOR_COLLECTION_NAME", dimension=2 + ) + assert isinstance(col, Collection) + del_res = col.drop( + TEST_CREATE_DELETE_VECTOR_COLLECTION_NAME + ) + assert del_res["status"]["ok"] == 1 + + @pytest.mark.describe("test of Database list_collections, sync") def test_database_list_collections_sync( self,