Skip to content

Commit e0ec8f0

Browse files
committed
1 parent 7bc6d0b commit e0ec8f0

7 files changed

Lines changed: 67 additions & 84 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
sudo apt-get -y install "postgresql-$POSTGRESQL_VERSION"
3535
- name: Install dependencies
3636
run: |
37-
pip install -e '.[test]'
37+
pip install -e . --group dev
3838
- name: Run tests
3939
env:
4040
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
sudo apt-get -y install "postgresql-$POSTGRESQL_VERSION"
3333
- name: Install dependencies
3434
run: |
35-
pip install -e '.[test]'
35+
pip install -e . --group dev
3636
- name: Run tests
3737
env:
3838
POSTGRESQL_VERSION: ${{ matrix.postgresql-version }}

conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
from django_sql_dashboard.models import Dashboard
55

66

7+
def pytest_collection_modifyitems(items):
8+
"""Add django_db marker with databases to tests that need database access."""
9+
for item in items:
10+
fixturenames = getattr(item, "fixturenames", ())
11+
# Tests using client fixtures or dashboard_db need both databases
12+
if any(f in fixturenames for f in ("admin_client", "client", "dashboard_db")):
13+
item.add_marker(pytest.mark.django_db(databases=["default", "dashboard"]))
14+
15+
716
@pytest.fixture
8-
def dashboard_db(settings, db):
17+
def dashboard_db(settings):
918
settings.DATABASES["dashboard"]["OPTIONS"] = {
1019
"options": "-c default_transaction_read_only=on -c statement_timeout=100"
1120
}

docs/contributing.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,22 @@
11
# Contributing
22

3-
To contribute to this library, first checkout the code. Then create a new virtual environment:
3+
To contribute to this library, first checkout the code. Use [uv](https://github.com/astral-sh/uv) to run the tests:
44

55
cd django-sql-dashboard
6-
python -m venv venv
7-
source venv/bin/activate
8-
9-
Or if you are using `pipenv`:
10-
11-
pipenv shell
12-
13-
Now install the dependencies and tests:
14-
15-
pip install -e '.[test]'
16-
17-
## Running the tests
18-
19-
To run the tests:
20-
21-
pytest
6+
uv run pytest
227

238
## Generating new migrations
249

2510
To generate migrations for model changes:
2611

2712
cd test_project
28-
./manage.py makemigrations
13+
uv run ./manage.py makemigrations
2914

3015
## Code style
3116

32-
This library uses [Black](https://github.com/psf/black) for code formatting. The correct version of Black will be installed by `pip install -e '.[test]'` - you can run `black .` in the root directory to apply those formatting rules.
17+
This library uses [Black](https://github.com/psf/black) for code formatting. You can run it like this:
18+
19+
uv run black .
3320

3421
## Documentation
3522

@@ -38,8 +25,7 @@ Documentation for this project uses [MyST](https://myst-parser.readthedocs.io/)
3825
To build the documentation locally, run the following:
3926

4027
cd docs
41-
pip install -r requirements.txt
42-
make livehtml
28+
uv run --with-requirements requirements.txt make livehtml
4329

4430
This will start a live preview server, using [sphinx-autobuild](https://pypi.org/project/sphinx-autobuild/).
4531

pyproject.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
[project]
2+
name = "django-sql-dashboard"
3+
version = "1.2"
4+
description = "Django app for building dashboards using raw SQL queries"
5+
readme = "README.md"
6+
license = "Apache-2.0"
7+
authors = [
8+
{ name = "Simon Willison" }
9+
]
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"Django>=4.2",
13+
"markdown",
14+
"bleach",
15+
]
16+
17+
[project.urls]
18+
Documentation = "https://django-sql-dashboard.datasette.io/"
19+
Issues = "https://github.com/simonw/django-sql-dashboard/issues"
20+
CI = "https://github.com/simonw/django-sql-dashboard/actions"
21+
Changelog = "https://github.com/simonw/django-sql-dashboard/releases"
22+
Homepage = "https://github.com/simonw/django-sql-dashboard"
23+
24+
[dependency-groups]
25+
dev = [
26+
"black>=22.3.0",
27+
"psycopg2",
28+
"pytest",
29+
"pytest-django>=4.11.1",
30+
"pytest-pythonpath",
31+
"dj-database-url",
32+
"testing.postgresql",
33+
"beautifulsoup4",
34+
"html5lib",
35+
]
36+
37+
[build-system]
38+
requires = ["hatchling"]
39+
build-backend = "hatchling.build"
40+
41+
[tool.hatch.build.targets.wheel]
42+
packages = ["django_sql_dashboard"]
43+
144
[tool.isort]
245
profile = "black"
346
multi_line_output = 3
47+
48+
[tool.pytest.ini_options]
49+
DJANGO_SETTINGS_MODULE = "config.settings"
50+
pythonpath = ["test_project", "pytest_plugins"]
51+
addopts = "-p pytest_use_postgresql"

pytest.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)