Skip to content

Commit 24d7e0c

Browse files
committed
Merge branch 'master' into asgi
2 parents 45883d0 + c836bf1 commit 24d7e0c

File tree

126 files changed

+6063
-1633
lines changed

Some content is hidden

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

126 files changed

+6063
-1633
lines changed

.all-contributorsrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@
4141
"contributions": [
4242
"code"
4343
]
44+
},
45+
{
46+
"login": "sbidy",
47+
"name": "Stephan Traub",
48+
"avatar_url": "https://avatars.githubusercontent.com/u/1077364?v=4",
49+
"profile": "https://github.com/sbidy",
50+
"contributions": [
51+
"test"
52+
]
53+
},
54+
{
55+
"login": "frbor",
56+
"name": "Fredrik Borg",
57+
"avatar_url": "https://avatars.githubusercontent.com/u/2320183?v=4",
58+
"profile": "https://github.com/frbor",
59+
"contributions": [
60+
"code",
61+
"test"
62+
]
4463
}
4564
],
4665
"contributorsPerLine": 7,

.dj-config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ long_running = true
1818

1919
[[commands]]
2020
name = "t"
21-
execute = "poetry run pytest tests && npm run-script test"
21+
execute = "poetry run pytest -m 'not slow' && poetry run pytest -m 'slow' && npm run-script test"
2222

2323
[[commands]]
2424
name = "is"

.flake8

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[flake8]
2-
max-line-length = 80
2+
max-line-length = 88
33
select = C,E,F,W,B,B950
4-
ignore = E501,W503
4+
ignore = E501,W503,E231
5+
extend-ignore = E203,W503

.github/workflows/python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
python-version: [3.6, 3.7]
9+
python-version: [3.6, 3.7, 3.8, 3.9]
1010

1111
steps:
1212
- uses: actions/[email protected]
@@ -45,5 +45,5 @@ jobs:
4545
- name: isort check
4646
run: poetry run isort --settings pyproject.toml --check .
4747

48-
- name: Test with pytest
49-
run: poetry run pytest tests
48+
- name: Run all tests
49+
run: poetry run nox

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ celerybeat-schedule
8383

8484
# Environments
8585
.env
86-
.venv
86+
.venv*
8787
env/
8888
venv/
8989
ENV/

DEVELOPING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Developing
2+
3+
1. `git clone [email protected]:adamghill/django-unicorn.git`
4+
1. `poetry install`
5+
1. `poetry run python example/manage.py migrate`
6+
1. `poetry run python example/manage.py runserver localhost:8000`
7+
1. Go to `localhost:8000` in your browser
8+
1. To install in another project `pip install -e ../django-unicorn`
9+
10+
## Run unittests
11+
12+
1. `poetry run pytest`
13+
1. `npm run test`
14+
15+
## Minify Javascript
16+
17+
1. `npm install`
18+
1. `npm run build`
19+
20+
## Bump version
21+
22+
1. `dj t`
23+
1. `npm run build`
24+
1. `poetry version major|minor|patch`
25+
1. Commit/tag/push version bump
26+
1. `poetry publish --build -r test`
27+
1. Make sure test package can be installed as expected (https://test.pypi.org/project/django-unicorn/)
28+
1. `poetry publish`
29+
1. Make sure live package can be installed as expected (https://pypi.org/project/django-unicorn/)
30+
1. [Create GitHub release](https://github.com/adamghill/django-unicorn/releases/new) and add changelog there
31+
1. Update django-unicorn.com's changelog.md
32+
1. Update django-unicorn.com's version of `django-unicorn`

README.md

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,32 @@
1-
# django-unicorn
1+
<p align="center">
2+
<a href="https://www.django-unicorn.com/"><img src="https://www.django-unicorn.com/static/img/unicorn.svg" alt="django-unicorn logo" height="80"/></a>
3+
</p>
4+
<h1 align="center">Unicorn</h1>
5+
<p align="center">The magical full-stack framework for Django ✨</p>
26

37
![PyPI](https://img.shields.io/pypi/v/django-unicorn?color=blue&style=flat-square)
48

5-
![GitHub Release Date](https://img.shields.io/github/release-date/adamghill/django-unicorn?style=flat-square)
6-
79
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
8-
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
10-
10+
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-)
1111
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1212

13-
The magical fullstack framework for Django. ✨
14-
15-
`Unicorn` is a reactive component framework that progressively enhances a normal Django view, makes AJAX calls in the background, and dynamically updates the DOM. It seamlessly extends Django past its server-side framework roots without giving up all of its niceties or re-building your website.
16-
17-
## Why?
18-
19-
Building server-side sites in Django with the ORM and template engine is so pleasant, but once you need more interactivity on the frontend, there is a lot more ambiguity. Should you build out an entire API in Django REST framework? Should you use React or Vue.js (or some) other frontend framework?
20-
21-
It seems like there should be an easier way to create interactive experiences.
22-
23-
## A note
24-
25-
`django-unicorn` is still beta and the API will likely change on the way to version 1.0.0. All efforts will be made to include an easy upgrade path. 1.0.0 will signify that the public API won't change until the next major release.
26-
27-
# Detailed documentation
28-
29-
https://www.django-unicorn.com
30-
31-
# Developing
32-
33-
1. `git clone [email protected]:adamghill/django-unicorn.git`
34-
1. `poetry install`
35-
1. `poetry run python example/manage.py migrate`
36-
1. `poetry run python example/manage.py runserver localhost:8000`
37-
1. Go to `localhost:8000` in your browser
38-
1. To install in another project `pip install -e ../django-unicorn`
39-
40-
## Run unittests
41-
42-
1. `poetry run pytest`
43-
1. `npm run test`
13+
[Unicorn](https://www.django-unicorn.com) is a reactive component framework that progressively enhances a normal Django view, makes AJAX calls in the background, and dynamically updates the DOM. It seamlessly extends Django past its server-side framework roots without giving up all of its niceties or re-building your website.
4414

45-
## Minify Javascript
15+
## :zap: How to use
4616

47-
1. `npm install`
48-
1. `npm run build`
17+
1. [Install](https://www.django-unicorn.com/docs/installation/) `Unicorn`
18+
1. [Create](https://www.django-unicorn.com/docs/components/) a component
19+
1. Load the `Unicorn` templatetag with `{% load unicorn %}` and add the component to your template with `{% unicorn 'component-name' %}`
20+
1. :tada:
4921

50-
## Bump version
22+
## :book: More details
5123

52-
1. `npm run build`
53-
1. `poetry version major|minor|patch`
54-
1. Commit/tag/push version bump
55-
1. `poetry publish --build -r test`
56-
1. Make sure test package can be installed as expected (https://test.pypi.org/project/django-unicorn/)
57-
1. `poetry publish`
58-
1. Make sure live package can be installed as expected (https://pypi.org/project/django-unicorn/)
59-
1. Update django-unicorn.com's changelog.md
60-
1. Update django-unicorn.com's version of `django-unicorn`
61-
1. [Create GitHub release](https://github.com/adamghill/django-unicorn/releases/new) and add changelog there
24+
- [Changelog](https://www.django-unicorn.com/docs/changelog/)
25+
- [Docs](https://www.django-unicorn.com/docs/)
26+
- [Screencasts](https://www.django-unicorn.com/screencasts/installation)
27+
- [Examples](https://www.django-unicorn.com/examples/todo)
6228

63-
## Contributors ✨
29+
## :clap: Contributors
6430

6531
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
6632

@@ -69,14 +35,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
6935
<!-- markdownlint-disable -->
7036
<table>
7137
<tr>
72-
<td align="center"><a href="https://adamghill.com"><img src="https://avatars0.githubusercontent.com/u/317045?v=4" width="100px;" alt=""/><br /><sub><b>Adam Hill</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=adamghill" title="Code">💻</a> <a href="https://github.com/adamghill/django-unicorn/commits?author=adamghill" title="Tests">⚠️</a></td>
73-
<td align="center"><a href="https://python3.ninja"><img src="https://avatars1.githubusercontent.com/u/44167?v=4" width="100px;" alt=""/><br /><sub><b>Andres Vargas</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=zodman" title="Code">💻</a></td>
74-
<td align="center"><a href="http://iskra.ml"><img src="https://avatars3.githubusercontent.com/u/6555851?v=4" width="100px;" alt=""/><br /><sub><b>Eddy Ernesto del Valle Pino</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=edelvalle" title="Code">💻</a></td>
75-
<td align="center"><a href="https://www.linkedin.com/in/yaser-al-najjar-429b9096/"><img src="https://avatars3.githubusercontent.com/u/10493809?v=4" width="100px;" alt=""/><br /><sub><b>Yaser Al-Najjar</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=yaseralnajjar" title="Code">💻</a></td>
38+
<td align="center"><a href="https://adamghill.com"><img src="https://avatars0.githubusercontent.com/u/317045?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Adam Hill</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=adamghill" title="Code">💻</a> <a href="https://github.com/adamghill/django-unicorn/commits?author=adamghill" title="Tests">⚠️</a></td>
39+
<td align="center"><a href="https://python3.ninja"><img src="https://avatars1.githubusercontent.com/u/44167?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andres Vargas</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=zodman" title="Code">💻</a></td>
40+
<td align="center"><a href="http://iskra.ml"><img src="https://avatars3.githubusercontent.com/u/6555851?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eddy Ernesto del Valle Pino</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=edelvalle" title="Code">💻</a></td>
41+
<td align="center"><a href="https://www.linkedin.com/in/yaser-al-najjar-429b9096/"><img src="https://avatars3.githubusercontent.com/u/10493809?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yaser Al-Najjar</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=yaseralnajjar" title="Code">💻</a></td>
42+
<td align="center"><a href="https://github.com/sbidy"><img src="https://avatars.githubusercontent.com/u/1077364?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephan Traub</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=sbidy" title="Tests">⚠️</a></td>
43+
<td align="center"><a href="https://github.com/frbor"><img src="https://avatars.githubusercontent.com/u/2320183?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fredrik Borg</b></sub></a><br /><a href="https://github.com/adamghill/django-unicorn/commits?author=frbor" title="Code">💻</a> <a href="https://github.com/adamghill/django-unicorn/commits?author=frbor" title="Tests">⚠️</a></td>
7644
</tr>
7745
</table>
7846

79-
<!-- markdownlint-enable -->
47+
<!-- markdownlint-restore -->
8048
<!-- prettier-ignore-end -->
8149

8250
<!-- ALL-CONTRIBUTORS-LIST:END -->

conftest.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from django.conf import settings
22

3+
import pytest
4+
35

46
def pytest_configure():
57
templates = [
@@ -11,13 +13,56 @@ def pytest_configure():
1113
databases = {"default": {"ENGINE": "django.db.backends.sqlite3",}}
1214

1315
installed_apps = [
14-
"example.coffee",
16+
"example.coffee.apps.Config",
17+
"example.books.apps.Config",
1518
]
1619

20+
unicorn_settings = {
21+
"SERIAL": {"ENABLED": True, "TIMEOUT": 5},
22+
"CACHE_ALIAS": "default",
23+
"APPS": ("unicorn",),
24+
}
25+
26+
caches = {
27+
"default": {
28+
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
29+
"LOCATION": "unique-snowflake",
30+
}
31+
}
32+
1733
settings.configure(
1834
TEMPLATES=templates,
1935
ROOT_URLCONF="django_unicorn.urls",
2036
DATABASES=databases,
2137
INSTALLED_APPS=installed_apps,
2238
UNIT_TEST=True,
39+
UNICORN=unicorn_settings,
40+
CACHES=caches,
2341
)
42+
43+
44+
@pytest.fixture(autouse=True)
45+
def reset_settings(settings):
46+
"""
47+
This takes the original `UNICORN` settings before the test is run, runs the test, and then resets them afterwards.
48+
This is required because mutating nested dictionaries does not reset them as expected by `pytest-django`.
49+
More details in https://github.com/pytest-dev/pytest-django/issues/601#issuecomment-440676001.
50+
"""
51+
52+
# Get original settings
53+
cache_settings = {**settings.CACHES}
54+
unicorn_settings = {**settings.UNICORN}
55+
django_unicorn_settings = {}
56+
57+
if hasattr(settings, "DJANGO_UNICORN"):
58+
django_unicorn_settings = {**settings.DJANGO_UNICORN}
59+
60+
# Run test
61+
yield
62+
63+
# Re-set original settings
64+
settings.CACHES = cache_settings
65+
settings.UNICORN = unicorn_settings
66+
67+
if django_unicorn_settings:
68+
settings.DJANGO_UNICORN = django_unicorn_settings

0 commit comments

Comments
 (0)