Skip to content

Commit fc89cde

Browse files
authored
Merge pull request #98 from eadwinCode/ninja_110_upgrade
Ninja V1.1.0 upgrade
2 parents 2b6f73f + 650f211 commit fc89cde

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

.github/workflows/test_full.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ['3.8', '3.9', '3.10', '3.11']
15-
django-version: ['<3.0', '<3.1', '<3.2', '<3.3', '<4.1', '<4.2']
16-
14+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
15+
django-version: [ '<3.2', '<3.3', '<4.2', '<4.3', '<5.1' ]
16+
exclude:
17+
- python-version: '3.8'
18+
django-version: '<5.1'
19+
- python-version: '3.9'
20+
django-version: '<5.1'
21+
- python-version: '3.12'
22+
django-version: '<3.2'
23+
- python-version: '3.12'
24+
django-version: '<3.3'
1725
steps:
1826
- uses: actions/checkout@v4
1927
- name: Set up Python
2028
uses: actions/setup-python@v4
2129
with:
2230
python-version: ${{ matrix.python-version }}
2331
- name: Install core
24-
run: pip install "Django${{ matrix.django-version }}"
32+
run: pip install --pre "Django${{ matrix.django-version }}"
2533
- name: Install tests
26-
run: pip install pytest 'pytest-asyncio==0.20.3' pytest-django 'injector>=0.19.0' 'django-ninja==1.0.1' asgiref contextlib2 'ninja-schema>=0.13.4'
34+
run: pip install pytest 'pytest-asyncio==0.20.3' pytest-django 'injector>=0.19.0' django-ninja asgiref contextlib2 'ninja-schema>=0.13.4'
2735
- name: Test
2836
run: pytest
2937
codestyle:

ninja_extra/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Django Ninja Extra - Class Based Utility and more for Django Ninja(Fast Django REST framework)"""
22

3-
__version__ = "0.20.0"
3+
__version__ = "0.20.2"
44

55
import django
66

ninja_extra/security/http.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
import logging
12
from abc import ABC, abstractmethod
23
from typing import Any, Optional
34

45
from django.conf import settings
56
from django.http import HttpRequest
6-
from ninja.compatibility import get_headers
7-
from ninja.security.http import DecodeError, HttpBasicAuth, HttpBearer, logger
7+
from ninja.security.http import DecodeError, HttpBasicAuth, HttpBearer
8+
9+
logger = logging.getLogger("django")
810

911
__all__ = ["AsyncHttpBearer", "AsyncHttpBasicAuth"]
1012

1113

1214
class AsyncHttpBearer(HttpBearer, ABC):
1315
async def __call__(self, request: HttpRequest) -> Optional[Any]:
14-
headers = get_headers(request)
16+
headers = request.headers
1517
auth_value = headers.get(self.header)
1618
if not auth_value:
1719
return None
@@ -31,7 +33,7 @@ async def authenticate(self, request: HttpRequest, token: str) -> Optional[Any]:
3133

3234
class AsyncHttpBasicAuth(HttpBasicAuth, ABC):
3335
async def __call__(self, request: HttpRequest) -> Optional[Any]:
34-
headers = get_headers(request)
36+
headers = request.headers
3537
auth_value = headers.get(self.header)
3638
if not auth_value:
3739
return None

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,22 @@ classifiers = [
2626
"Programming Language :: Python :: 3.9",
2727
"Programming Language :: Python :: 3.10",
2828
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
2930
"Programming Language :: Python :: 3 :: Only",
3031
"Framework :: Django",
31-
"Framework :: Django :: 2.1",
32-
"Framework :: Django :: 2.2",
33-
"Framework :: Django :: 3.0",
3432
"Framework :: Django :: 3.1",
3533
"Framework :: Django :: 3.2",
36-
"Framework :: Django :: 4.0",
3734
"Framework :: Django :: 4.1",
35+
"Framework :: Django :: 4.2",
36+
"Framework :: Django :: 5.0",
3837
"Framework :: AsyncIO",
3938
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
4039
"Topic :: Internet :: WWW/HTTP",
4140
]
4241

4342
requires = [
4443
"Django >= 2.2",
45-
"django-ninja==1.0.1",
44+
"django-ninja==1.1.0",
4645
"injector >= 0.19.0",
4746
"asgiref",
4847
"contextlib2"

tests/test_event_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ def test_get_event_works(self, path):
6565
response = client.get(path.format(event_id=event.id))
6666
assert response.status_code == 200
6767
data = response.json()
68-
event_schema = json.loads(EventSchema.from_orm(event).json())
68+
event_schema = json.loads(EventSchema.from_orm(event).model_dump_json())
6969
assert event_schema == data

tests/test_model_controller/test_model_controller_configurations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_default_model_config():
3535
"paginator_kwargs": None,
3636
"pagination_schema": PaginatedResponseSchema,
3737
}
38-
assert model_config.schema_config.dict() == {
38+
assert model_config.schema_config.model_dump() == {
3939
"include": "__all__",
4040
"exclude": set(),
4141
"optional": None,
@@ -60,7 +60,7 @@ def test_include_gen_schema():
6060
assert model_config.create_schema is None
6161
assert model_config.patch_schema is None
6262
assert model_config.update_schema is None
63-
assert model_config.retrieve_schema.schema() == {
63+
assert model_config.retrieve_schema.model_json_schema() == {
6464
"properties": {
6565
"id": {"description": "", "title": "Id", "type": "integer"},
6666
"title": {
@@ -97,7 +97,7 @@ def test_exclude_gen_schema():
9797
assert model_config.create_schema is None
9898
assert model_config.patch_schema is None
9999
assert model_config.update_schema is None
100-
assert model_config.retrieve_schema.schema() == {
100+
assert model_config.retrieve_schema.model_json_schema() == {
101101
"properties": {
102102
"id": {"description": "", "title": "Id", "type": "integer"},
103103
"title": {

0 commit comments

Comments
 (0)