Skip to content

Commit 91342bc

Browse files
committed
Refactor Python tests to use unified property access method
- Updated all test files to replace `get_property` method calls with the new `get` method for consistency and improved readability. - Adjusted comments to reflect the use of Python API instead of Java API where applicable. - Ensured that all assertions in tests are aligned with the new method signatures.
1 parent 2a08aa7 commit 91342bc

86 files changed

Lines changed: 3730 additions & 1487 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ with arcadedb.create_database("/tmp/mydb") as db:
5757
# READ: Query data
5858
result = db.query("sql", "SELECT FROM Person WHERE age > 20")
5959
for record in result:
60-
print(f"{record.get_property('name')} - {record.get_property('age')}")
60+
print(f"{record.get('name')} - {record.get('age')}")
6161

6262
# UPDATE: Modify records
6363
with db.transaction():

bindings/python/Dockerfile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ try:\n\
210210
\n\
211211
result = db.query("sql", "SELECT FROM TestDoc")\n\
212212
for record in result:\n\
213-
print(f"✅ Query result: {record.get_property('\''name'\'')} = {record.get_property('\''value'\'')}")\n\
213+
print(f"✅ Query result: {record.get('\''name'\'')} = {record.get('\''value'\'')}")\n\
214214
\n\
215215
print("🎉 All tests passed!")\n\
216216
finally:\n\

bindings/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ with arcadedb.create_database("/tmp/mydb") as db:
5757
# Query data
5858
result = db.query("sql", "SELECT FROM Person WHERE age > 25")
5959
for record in result:
60-
print(f"Name: {record.get_property('name')}")
60+
print(f"Name: {record.get('name')}")
6161
```
6262

6363
**[👉 See full tutorial](https://humemai.github.io/arcadedb-embedded-python/latest/getting-started/quickstart/)**

bindings/python/docs/api-access-methods.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ with arcadedb.create_database("/tmp/mydb") as db:
3131
# Query data
3232
result = db.query("sql", "SELECT FROM Person WHERE age > 25")
3333
for record in result:
34-
print(f"Name: {record.get_property('name')}")
34+
print(f"Name: {record.get('name')}")
3535
```
3636

3737
**Server-Managed Database (Optional):**
@@ -53,7 +53,7 @@ try:
5353

5454
result = db.query("sql", "SELECT FROM Person WHERE age > 25")
5555
for record in result:
56-
print(f"Name: {record.get_property('name')}")
56+
print(f"Name: {record.get('name')}")
5757

5858
finally:
5959
server.stop()

bindings/python/docs/api/async_executor.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Schedule asynchronous record creation.
194194

195195
**Parameters:**
196196

197-
- `record`: Java MutableDocument or Vertex to create
197+
- `record`: Document, Vertex, or Edge object to create
198198
- `callback` (Optional[Callable]): Success callback
199199

200200
**Example:**
@@ -227,7 +227,7 @@ Schedule asynchronous record update.
227227

228228
**Parameters:**
229229

230-
- `record`: Java MutableDocument to update
230+
- `record`: Document, Vertex, or Edge object to update
231231
- `callback` (Optional[Callable]): Success callback
232232

233233
**Example:**
@@ -239,9 +239,10 @@ results = list(db.query("sql", "SELECT FROM User WHERE active = false"))
239239
async_exec = db.async_executor()
240240

241241
for result in results:
242-
record = result._java_result.getElement().get()
243-
record.set("active", True)
244-
async_exec.update_record(record)
242+
element = result.get_element()
243+
mutable = element.modify()
244+
mutable.set("active", True)
245+
async_exec.update_record(mutable)
245246

246247
async_exec.wait_completion()
247248
async_exec.close()
@@ -262,7 +263,7 @@ Schedule asynchronous record deletion.
262263

263264
**Parameters:**
264265

265-
- `record`: Java record to delete
266+
- `record`: Document, Vertex, or Edge object to delete
266267
- `callback` (Optional[Callable]): Success callback
267268

268269
**Example:**
@@ -275,8 +276,8 @@ to_delete = list(db.query("sql", "SELECT FROM LogEntry WHERE timestamp < ?",
275276
async_exec = db.async_executor()
276277

277278
for result in to_delete:
278-
record = result._java_result.getElement().get()
279-
async_exec.delete_record(record)
279+
element = result.get_element()
280+
async_exec.delete_record(element)
280281

281282
async_exec.wait_completion()
282283
async_exec.close()
@@ -309,7 +310,7 @@ Execute async query.
309310
```python
310311
def process_results(resultset):
311312
for result in resultset:
312-
print(result.get_property("name"))
313+
print(result.get("name"))
313314

314315
async_exec = db.async_executor()
315316
async_exec.query("sql", "SELECT FROM User WHERE age > 18", process_results)

bindings/python/docs/api/batch.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ with db.batch_context() as batch:
197197
```
198198

199199
!!! note "Edge Creation is Synchronous"
200-
Unlike vertex/document creation, edge creation with `newEdge()` is synchronous and immediately persists the edge. The callback is called immediately after creation.
200+
Unlike vertex/document creation, edge creation with `new_edge()` is synchronous and
201+
immediately persists the edge. The callback is called immediately after creation.
201202

202203
---
203204

@@ -225,8 +226,8 @@ to_delete = list(db.query("sql", "SELECT FROM User WHERE inactive = true"))
225226

226227
with db.batch_context() as batch:
227228
for result in to_delete:
228-
java_record = result._java_result.getElement().get()
229-
batch.delete_record(java_record)
229+
element = result.get_element()
230+
batch.delete_record(element)
230231
```
231232

232233
---

bindings/python/docs/api/database.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Execute a query and return results. Queries are read-only and don't require a tr
151151
# Simple query
152152
result = db.query("sql", "SELECT FROM Person WHERE age > 25")
153153
for record in result:
154-
print(record.get_property('name'))
154+
print(record.get('name'))
155155

156156
# Parameterized query
157157
result = db.query("sql", "SELECT FROM Person WHERE age > ?", 25)
@@ -337,13 +337,13 @@ with db.transaction():
337337
vertex.set("age", 30)
338338
vertex.save()
339339

340-
print(f"Created: {vertex.getIdentity()}")
340+
print(f"Created: {vertex.get_rid()}")
341341
```
342342

343343
!!! info "Creating Edges"
344344
There is no `db.new_edge()` method. Edges are created **from vertices**:
345345
```python
346-
edge = vertex1.newEdge("Knows", vertex2)
346+
edge = vertex1.new_edge("Knows", vertex2)
347347
edge.save()
348348
```
349349
See [Graph Operations](../guide/graphs.md) for details.
@@ -413,8 +413,7 @@ db.create_vector_index(
413413
dimensions: int,
414414
distance_function: str = "cosine",
415415
max_connections: int = 32,
416-
beam_width: int = 256,
417-
quantization: str = None
416+
beam_width: int = 256
418417
) -> VectorIndex
419418
```
420419

@@ -430,7 +429,6 @@ Create a vector index for similarity search (default JVector implementation).
430429
- `distance_function` (str): `"cosine"`, `"euclidean"`, or `"inner_product"`
431430
- `max_connections` (int): Max connections per node (default: 32). Maps to `maxConnections` in JVector.
432431
- `beam_width` (int): Beam width for search/construction (default: 256). Maps to `beamWidth` in JVector.
433-
- `quantization` (str): Vector quantization type (default: None). Options: `"INT8"`, `"BINARY"`. Reduces memory usage and speeds up search at the cost of some precision.
434432

435433
**Returns:**
436434

bindings/python/docs/api/exceptions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ try:
144144
person = result.next()
145145

146146
# Property might not exist
147-
phone = person.get_property("phone_number") # Typo or missing
147+
phone = person.get("phone_number") # Typo or missing
148148

149149
except ArcadeDBError as e:
150150
print(f"Property error: {e}")
@@ -288,7 +288,7 @@ def get_user_safely(db, email):
288288
# Usage
289289
user = get_user_safely(db, "alice@example.com")
290290
if user:
291-
print(f"Found user: {user.get_property('name')}")
291+
print(f"Found user: {user.get('name')}")
292292
else:
293293
print("User not found or error occurred")
294294
```

0 commit comments

Comments
 (0)