Skip to content

Commit cf9ac9f

Browse files
committed
Add yet broken tests
1 parent aa0aa39 commit cf9ac9f

22 files changed

+1986
-8
lines changed

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.idea/
2+
.vscode/
3+
# Byte-compiled / optimized / DLL files
4+
pycache/
5+
__pycache__
6+
*.py[cod]
7+
*$py.class
8+
__test*
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# Unit test / coverage reports
34+
htmlcov/
35+
.tox/
36+
.nox/
37+
.coverage
38+
.coverage.*
39+
.cache
40+
nosetests.xml
41+
coverage.xml
42+
*.cover
43+
*.py,cover
44+
.hypothesis/
45+
.pytest_cache/
46+
cover/
47+
48+
# Environments
49+
.env
50+
.gen.env
51+
.venv
52+
env/
53+
venv/
54+
ENV/
55+
env.bak/
56+
venv.bak/
57+
58+
# mypy
59+
.mypy_cache/
60+
.dmypy.json
61+
dmypy.json
62+
63+
# Cython debug symbols
64+
cython_debug/

piccolo_conf.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""This piccolo_conf file is just here so migrations can be made for Piccolo's own internal apps.
2+
3+
For example:
4+
5+
python -m piccolo.main migration new user --auto
6+
7+
"""
8+
9+
import os
10+
11+
from piccolo.conf.apps import AppRegistry
12+
13+
from psqlpy_piccolo import PSQLPyEngine as Engine
14+
15+
DB = Engine(
16+
config={
17+
"host": os.environ.get("PG_HOST", "127.0.0.1"),
18+
"port": os.environ.get("PG_PORT", 5432),
19+
"user": os.environ.get("PG_USER", "postgres"),
20+
"password": os.environ.get("PG_PASSWORD", "postgres"),
21+
"database": os.environ.get("PG_DATABASE", "piccolo"),
22+
},
23+
)
24+
25+
# from piccolo.apps.migrations.tables
26+
APP_REGISTRY = AppRegistry(
27+
apps=[
28+
"piccolo.apps.migrations.piccolo_app",
29+
"tests.test_apps.mega.piccolo_app",
30+
"tests.test_apps.music.piccolo_app",
31+
],
32+
)

poetry.lock

Lines changed: 513 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psqlpy_piccolo/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Package with piccolo engine based on psqlpy driver."""
2+
3+
from psqlpy_piccolo.engine import PSQLPyEngine
4+
5+
__all__ = ("PSQLPyEngine",)
148 Bytes
Binary file not shown.
Binary file not shown.

psqlpy_piccolo/engine.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,13 @@ async def start_connection_pool(self: Self, **kwargs: Dict[str, Any]) -> None:
530530
else:
531531
config = dict(self.config)
532532
config.update(**kwargs)
533+
print("----------------")
534+
print(config)
535+
print("----------------")
533536
self.pool = ConnectionPool(
534537
db_name=config.pop("database", None),
535538
username=config.pop("user", None),
536-
max_db_pool_size=config.pop("max_size"),
539+
max_db_pool_size=config.pop("max_size", 2),
537540
**config,
538541
)
539542

@@ -622,7 +625,6 @@ async def _run_in_new_connection(
622625
Result from the database as a list of dicts.
623626
"""
624627
connection = await self.get_new_connection()
625-
626628
try:
627629
results = await connection.execute(
628630
querystring=query,
@@ -647,6 +649,9 @@ async def run_querystring(
647649
### Returns:
648650
Result from the database as a list of dicts.
649651
"""
652+
print("------------------")
653+
print("RUN", querystring)
654+
print("------------------")
650655
query, query_args = querystring.compile_string(engine_type=self.engine_type)
651656

652657
query_id = self.get_query_id()
@@ -669,7 +674,7 @@ async def run_querystring(
669674

670675
if self.log_responses:
671676
self.print_response(query_id=query_id, response=response)
672-
677+
print(response)
673678
return response
674679

675680
async def run_ddl(

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ readme = "README.md"
88
[tool.poetry.dependencies]
99
python = "^3.8"
1010
psqlpy = "^0.6.0"
11-
piccolo = "^1.12.0"
11+
piccolo = {version = "^1.13.1", extras = ["postgres"]}
1212

1313

1414
[tool.poetry.group.lint.dependencies]
1515
ruff = "^0.4.7"
1616
black = "^24.4.2"
1717
isort = "^5.13.2"
1818

19+
20+
[tool.poetry.group.dev.dependencies]
21+
anyio = "^4.4.0"
22+
pytest = "^8.3.1"
23+
pytest-cov = "^5.0.0"
24+
trio = "^0.26.0"
25+
1926
[build-system]
2027
requires = ["poetry-core"]
2128
build-backend = "poetry.core.masonry.api"

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pytest
2+
3+
pytestmark = [pytest.mark.anyio]
4+
5+
6+
@pytest.fixture(scope="session", autouse=True)
7+
def anyio_backend() -> str:
8+
return "asyncio"

tests/test_apps/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)