Core Database Tests¶
The tests cover 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
- Result sets of 1,000 records (no timing is asserted)
- Type conversions (Python ↔ Java)
- RID lookup via
lookup_by_rid() run_in_transaction()commit and rollback on any exception, includingBaseException- Bulk materialization (
to_json_list(),to_columns(),to_dataframe())
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_run_in_transaction_commits_and_returns:
run_in_transaction()runsfntransactionally and hands back its return value; a non-retryableArcadeDBErrorfromfnpropagates and its insert is rolled back - test_run_in_transaction_rolls_back_on_non_arcadedb_error: A plain
KeyErrorfromfnstill rolls back and leaves no open transaction (regression test for #7108) - test_run_in_transaction_rolls_back_on_base_exception:
SystemExitis aBaseException, soexcept Exceptionlet it skip the rollback; the test raisesSystemExitfromfnand asserts no transaction is left open and nothing was stored - 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);
dateis only checked to be non-null - test_single_list_arg_is_positional_param_array: A single list argument binds one element per
?placeholder, the idiom example 04's CSV ingest uses; a list among several arguments stays one parameter (vectorCosineSimilarity(?, ?)returns 1.0)
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 - test_fulltext_search_bm25_term_boosts: BM25 scoring honours per-term caret boosts (
term^weight) in the query string
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
Result Materialization¶
- test_to_json_list_bulk_materialization:
to_json_list(batch_size=10)returns all 25 rows across several Java batches, with JSON-native values; thencolumn matchesto_list() - test_to_json_list_empty_result:
to_json_list()on an empty result is an empty list - test_to_columns_typed_bulk_materialization:
to_columns()returns typed numpy columns with pandas-convention nulls - test_to_columns_survives_json_metacharacters_in_aliases: A projection alias is arbitrary text, so the columnar header has to be real JSON (#6758): aliases containing a quote and a semicolon come back as the column names, with their values, across batches of 2 rows
- test_to_dataframe_fast_path:
to_dataframe()returns 50 rows with an integer dtype fornand the expectednamein row 3 (skips without pandas). The test does not check which path built it - test_resultset_close_and_context_manager:
ResultSetsupportsclose()and the context-manager protocol
Parameter Binding (test_parameter_binding.py)¶
query(), command(), and the async executor hand the engine one typed argument: an Object[] for positional parameters and a java.util.Map for named ones (humemai/arcadedb-embedded-python#172). Before, command() with a lone None raised Ambiguous overloads.
- a lone null binds:
None,[None], and(None,)oncommand()insert and update a property to null, select records in anUPDATE ... WHERE v <=> ?, and onquery()select the record whosevis null - null then a value:
(None, 1)on both binds both - named parameters: a dict on both binds
:v(null) and:w; a list holding one dict is still the named map, in SQL and in openCypher - async:
args=[None],(None,), and[None, 1]store a null without an error - one Java overload per shape: a JPype proxy of the
Databaseinterface, and ofDatabaseAsyncExecutor, records the argument each shape arrives as
Other Features¶
- test_error_handling:
arcadedb.open_database()on an invalid path raisesArcadeDBError - test_failed_open_does_not_hang_process_exit: A failed
open_database()must leave the process able to exit: a child process that fails an open exits 0 within 60 s (regression test for a leaked non-daemon AsyncFlush thread) - 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