Skip to content

Commit c5999c0

Browse files
authored
move python test from postgres to to e2e-python (#3269)
1 parent 2e369a4 commit c5999c0

7 files changed

Lines changed: 386 additions & 315 deletions

File tree

e2e-python/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,52 @@ uv pip install -e .
1919
```bash
2020
pytest
2121
```
22+
23+
## asyncpg Tests
24+
25+
Tests for PostgreSQL wire protocol compatibility using the Python asyncpg driver.
26+
27+
### Related Issues
28+
29+
- [#1630](https://github.com/ArcadeData/arcadedb/issues/1630) - Bind message parsing with asyncpg
30+
- [#668](https://github.com/ArcadeData/arcadedb/issues/668) - asyncpg compatibility
31+
32+
### Prerequisites
33+
34+
```bash
35+
cd e2e-python
36+
pip install -e .
37+
```
38+
39+
### Running Tests
40+
41+
```bash
42+
# All asyncpg tests
43+
pytest tests/test_asyncpg.py -v
44+
45+
# Specific test
46+
pytest tests/test_asyncpg.py::test_parameterized_select -v
47+
48+
# With logging
49+
pytest tests/test_asyncpg.py -v --log-cli-level=DEBUG
50+
```
51+
52+
### Test Coverage
53+
54+
1. **Basic Connection** - Verify asyncpg can connect to ArcadeDB
55+
2. **Simple Queries** - SELECT queries without parameters
56+
3. **Type Creation** - CREATE DOCUMENT TYPE and INSERT operations
57+
4. **Parameterized Queries** (Issue #1630)
58+
- Single parameter SELECT
59+
- Multiple parameter SELECT
60+
- Parameterized INSERT
61+
5. **Transactions** - Transaction commit and rollback support
62+
63+
### Container Management
64+
65+
Tests use testcontainers to automatically:
66+
- Pull arcadedata/arcadedb:latest image
67+
- Start container with PostgreSQL plugin enabled
68+
- Create asyncpg_testdb database
69+
- Wait for server readiness
70+
- Clean up after tests

e2e-python/pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ dependencies = [
2626
"testcontainers>=4.9.1",
2727
"pytest>=8.3.4",
2828
"pytest-check>=2.5.0",
29+
"pytest-asyncio>=0.23.0",
2930
"docker>=7.1.0",
3031
"psycopg>=3.2.5",
3132
"psycopg-binary>=3.2.5",
33+
"asyncpg>=0.29.0",
34+
"requests>=2.31.0"
3235
]
3336

3437
[build-system]
@@ -37,3 +40,20 @@ build-backend = "setuptools.build_meta"
3740

3841
[tool.setuptools]
3942
packages = ["tests"]
43+
44+
[tool.pytest.ini_options]
45+
minversion = "8.0"
46+
testpaths = ["tests"]
47+
python_files = ["test_*.py"]
48+
python_classes = ["Test*"]
49+
python_functions = ["test_*"]
50+
asyncio_mode = "auto"
51+
markers = [
52+
"asyncio: mark test as asyncio test",
53+
]
54+
# Show test durations
55+
addopts = [
56+
"-v",
57+
"--durations=10",
58+
"--strict-markers",
59+
]

e2e-python/tests/test_arcadedb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ def test_psycopg2_basic_queries():
102102

103103
# Create a new document type
104104
cursor.execute("CREATE DOCUMENT TYPE TestProduct")
105+
cursor.execute("CREATE PROPERTY TestProduct.price INTEGER")
105106

106107
# Insert data
107-
cursor.execute("INSERT INTO TestProduct (name, price) VALUES ('TestItem', 29.99)")
108+
cursor.execute("INSERT INTO TestProduct (name, price) VALUES ('TestItem', 29)")
108109

109110
# Query the inserted data
110111
cursor.execute("SELECT * FROM TestProduct")
@@ -116,7 +117,7 @@ def test_psycopg2_basic_queries():
116117
product = products[0]
117118
print(f"Product: {product}")
118119
assert 'TestItem' in product
119-
assert 29.99 in product
120+
assert '29' in product
120121
finally:
121122
conn.close()
122123

0 commit comments

Comments
 (0)