Core Database Tests¶
There are 25 tests covering fundamental database operations.
Overview¶
Tests validate:
- Database creation and context managers
- CRUD operations (Create, Read, Update, Delete)
- Transaction management and ACID behavior
- Graph operations (vertex/edge creation and traversal)
- Query result handling and iteration
- Error handling
- OpenCypher queries (when available)
- SQL aggregate behavior on empty types
- Full-text search (
SEARCH_INDEX,$score, wildcards) - SQLScript,
UPDATE/DELETEBATCH,UPDATE ... CONTENT,TRUNCATE BUCKET,FIND REFERENCES - Unicode/international character support
- Schema introspection and metadata
- Large result sets (1000+ records)
- Type conversions (Python ↔ Java)
- RID lookup via
lookup_by_rid()
Test Cases¶
Database Management¶
- test_database_creation: Creates a new database via
arcadedb.create_database()and verifiesis_open()before and afterclose() - test_database_operations: Uses a
withcontext manager to create aTestDoctype, insert in a transaction, and query it back
CRUD Operations¶
- test_rich_data_types: Defines a
Tasktype with STRING/BOOLEAN/INTEGER/FLOAT/DECIMAL/DATE/DATETIME properties, uses built-in functions (uuid(),date(),sysdate()), then exercises insert, aggregation, filtering, UPDATE, and DELETE - test_arcadedb_sql_features: Tests built-in SQL functions and JSON-like embedded document properties on
TestEntity(metadata returns a Java map-like object) - test_transactions: Tests successful commit and automatic rollback on exception
- test_result_methods: Tests
Resultmethods:has_property(),get(),get_property_names(),to_dict(),to_json() - test_property_type_conversions: Tests Python ↔ Java type mapping (str, int, long, float, double, bool, None, date)
Full-text Search¶
- test_fulltext_search_with_score: Creates a
FULL_TEXTindex onArticle.contentand verifiesSEARCH_INDEX(...)results expose$score - test_fulltext_search_preserves_wildcards: Verifies wildcard queries (
Hel*) reach the full-text index unchanged
SQL Statement Coverage¶
- test_sql_count_on_empty_type_returns_zero:
count(*)on an empty type returns a row with0 - test_sqlscript_returns_last_command_result:
sqlscriptreturns the last command's result when no explicitRETURNis used - test_update_with_json_array_content:
UPDATE ... CONTENT [...]supports JSON arrays for multi-document updates withRETURN AFTER - test_truncate_bucket:
TRUNCATE BUCKETremoves all records in a bucket (usescount_type()) - test_update_batch_clause:
UPDATE ... BATCHexecutes through the Python SQL pass-through - test_delete_batch_clause:
DELETE ... BATCHexecutes through the Python SQL pass-through - test_find_references_returns_referring_record:
FIND REFERENCESreturns the record pointing to a target RID
Graph Operations¶
- test_graph_operations: Creates
Personvertices and aKnowsedge via SQL, then traverses without('Knows') - test_create_edge_with_content_object_preserves_properties:
CREATE EDGE ... CONTENT {...}keeps object-form properties - test_complex_graph_traversal: Multi-hop traversal across
Follows/Likesedges on a small social graph - test_lookup_by_rid: Creates a vertex with
db.new_vertex(...)/save(), then resolves it withdb.lookup_by_rid(); invalid RID raisesArcadeDBError
Query Languages¶
- test_opencypher_queries: Tests OpenCypher
CREATEandMATCHqueries (skips if the opencypher engine is unavailable)
Other Features¶
- test_error_handling:
arcadedb.open_database()on an invalid path raisesArcadeDBError - test_unicode_support: Tests UTF-8 international characters (Spanish, Chinese, Japanese, Arabic) and emoji
- test_schema_queries: Tests schema metadata via
SELECT FROM schema:types,schema:indexes, andschema:database - test_large_result_set_handling: Bulk-inserts 1000 records and tests ordered iteration, filtering, and aggregation
Key Patterns¶
# Database lifecycle
with arcadedb.create_database("./test_db") as db:
# Use database
pass # Auto-closes
# Transaction pattern
with db.transaction():
rec = db.new_document("Type")
rec.set("key", "value").save()
# Auto-commits on success, auto-rollback on error
# Query and iterate
result_set = db.query("sql", "SELECT FROM Type")
for result in result_set:
value = result.get("field")
# Process...
# Graph traversal
vertex = db.new_vertex("Person")
vertex.set("name", "Alice").save()
knows_edges = vertex.get_out_edges("Knows") # outgoing "Knows" edges
friends = [edge.get_in() for edge in knows_edges] # neighbor vertices