Skip to content

Server Tests

View source code

These tests cover server creation, database operations, custom config, context managers, and the default host. For advanced patterns (embedded + HTTP), see Server Patterns.

Note: the tests construct the server directly with the ArcadeDBServer class. Every test except test_default_host_is_localhost is marked @pytest.mark.server. None skips: the wheel always ships the server stack, and a missing one fails these tests.

Quick Example

import arcadedb_embedded as arcadedb

# Create and start server
server = arcadedb.create_server(
    root_path="./databases",
    root_password="mypassword"
)
server.start()

# Create database
# "mydb" will be created at ./databases/databases/mydb
db = server.create_database("mydb")

# Use it
db.command("sql", "CREATE DOCUMENT TYPE Person")
with db.transaction():
    person = db.new_document("Person")
    person.set("name", "Alice").save()

# Query
result = db.query("sql", "SELECT FROM Person")
for person in result:
    print(person.get("name"))

# Stop server
server.stop()

Test Cases

1. Server Creation and Startup

Test: test_server_creation

from arcadedb_embedded import ArcadeDBServer

server = ArcadeDBServer(
    root_path="./databases",
    root_password="mypassword",
    config={"http_port": 2480},
)

assert not server.is_started()
server.start()
assert server.is_started()

assert server.get_http_port() == 2480
studio_url = server.get_studio_url()
assert "http://" in studio_url
assert "2480" in studio_url

server.stop()
assert not server.is_started()

2. Database Operations Through Server

Test: test_server_database_operations

from arcadedb_embedded import ArcadeDBServer

with ArcadeDBServer(root_path="./databases", root_password="mypassword") as server:
    # Server auto-starts in the context manager

    # Create database through server
    db = server.create_database("testdb")
    assert db.is_open()

    db.command("sql", "CREATE DOCUMENT TYPE Person")
    with db.transaction():
        db.command("sql", "INSERT INTO Person SET name = 'Alice', age = 30")

    records = list(db.query("sql", "SELECT FROM Person"))
    assert len(records) == 1
    assert records[0].get("name") == "Alice"
    db.close()

3. Custom Configuration

Test: test_server_custom_config

from arcadedb_embedded import ArcadeDBServer

server = ArcadeDBServer(
    root_path="./databases",
    root_password="secure_password",
    config={
        "http_port": 8080,
        "host": "127.0.0.1",
        "mode": "production"
    }
)
server.start()

assert server.get_http_port() == 8080
server.stop()

4. Context Manager

Test: test_server_context_manager

with ArcadeDBServer(root_path="./databases", root_password="mypassword") as server:
    # Server auto-starts in the context manager
    assert server.is_started()
    # The test does not check that the server stopped after the block

5. Default Host

Test: test_default_host_is_localhost

Verifies that the default host is localhost (binding to all interfaces must be opt-in). The server is not started here; the assertion is made on the publicly-observable Studio URL, which is a faithful proxy for the configured host.

from arcadedb_embedded.server import ArcadeDBServer

server = ArcadeDBServer(root_path="./databases", root_password="mypassword")
assert server.get_studio_url().startswith("http://localhost:")

Running These Tests

# Run all server tests (from the repository root)
uv run pytest bindings/python/tests/test_server.py -v

# Run specific test
uv run pytest bindings/python/tests/test_server.py::test_server_creation -v