diff --git a/arango/collection.py b/arango/collection.py index 0f43f397..c62840a9 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -400,6 +400,8 @@ def configure( if sync is not None: data["waitForSync"] = sync if schema is not None: + if not isinstance(schema, dict) or len(schema) == 0: + raise ValueError("schema parameter must be a non-empty dict") data["schema"] = schema if replication_factor is not None: data["replicationFactor"] = replication_factor diff --git a/arango/database.py b/arango/database.py index 48a032d7..2ba1129b 100644 --- a/arango/database.py +++ b/arango/database.py @@ -1668,6 +1668,7 @@ def create_collection( :return: Standard collection API wrapper. :rtype: arango.collection.StandardCollection :raise arango.exceptions.CollectionCreateError: If create fails. + :raise ValueError: If parameters are invalid. """ key_options: Json = {"type": key_generator, "allowUserKeys": user_keys} if key_generator == "autoincrement": @@ -1698,6 +1699,8 @@ def create_collection( if write_concern is not None: data["writeConcern"] = write_concern if schema is not None: + if not isinstance(schema, dict) or len(schema) == 0: + raise ValueError("schema parameter must be a non-empty dict") data["schema"] = schema if computedValues is not None: data["computedValues"] = computedValues diff --git a/arango/formatter.py b/arango/formatter.py index ebbb070c..eeb50e77 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -1112,7 +1112,7 @@ def format_backup_dbserver(body: Json) -> Json: :return: Formatted body. :rtype: dict """ - return {"status": body["Status"]} + return {"status": body.get("Status")} def format_backup_transfer(body: Json) -> Json: diff --git a/arango/version.py b/arango/version.py index a0c45555..ec400e65 100644 --- a/arango/version.py +++ b/arango/version.py @@ -1 +1 @@ -__version__ = "8.2.6" +__version__ = "8.3.0" diff --git a/docs/schema.rst b/docs/schema.rst index e56943e5..fdfeccfc 100644 --- a/docs/schema.rst +++ b/docs/schema.rst @@ -3,7 +3,7 @@ Schema Validation ArangoDB supports document validation using JSON schemas. You can use this feature by providing a schema during collection creation using the ``schema`` -parameter. +parameter. It must not be an empty ``dict```. **Example:** @@ -37,6 +37,3 @@ parameter. # Modify the schema. employees.configure(schema=my_schema) - - # Remove the schema. - employees.configure(schema={}) diff --git a/tests/test_backup.py b/tests/test_backup.py index 9b157024..1fea7ecd 100644 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -1,3 +1,5 @@ +import time + import pytest from packaging import version @@ -110,6 +112,9 @@ def test_backup_management(sys_db, bad_db, cluster, skip_tests, db_version): result = sys_db.backup.restore(backup_id_foo) assert isinstance(result, dict) + # Wait for restore to complete + time.sleep(10) + # Test restore backup with bad database. with assert_raises(BackupRestoreError) as err: bad_db.backup.restore(backup_id_foo) diff --git a/tests/test_collection.py b/tests/test_collection.py index c1b2c2f0..0f0f2d3a 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -60,9 +60,13 @@ def test_collection_misc_methods(col, bad_col, cluster): } ] - properties = col.configure( - sync=not prev_sync, schema={}, computed_values=computed_values - ) + with pytest.raises(ValueError): + # schema must not be empty + properties = col.configure( + sync=not prev_sync, schema={}, computed_values=computed_values + ) + + properties = col.configure(sync=not prev_sync, computed_values=computed_values) assert properties["name"] == col.name assert properties["system"] is False @@ -202,6 +206,10 @@ def test_collection_management(db, bad_db, cluster): col_name = generate_col_name() + with pytest.raises(ValueError): + # schema must not be empty + db.create_collection(name=col_name, schema={}) + col = db.create_collection( name=col_name, sync=True,