Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ninja V1.1.0 upgrade #98

Merged
merged 7 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
django-version: ['<3.0', '<3.1', '<3.2', '<3.3', '<4.1', '<4.2']

python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
django-version: [ '<3.2', '<3.3', '<4.2', '<4.3', '<5.1' ]
exclude:
- python-version: '3.8'
django-version: '<5.1'
- python-version: '3.9'
django-version: '<5.1'
- python-version: '3.12'
django-version: '<3.2'
- python-version: '3.12'
django-version: '<3.3'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install core
run: pip install "Django${{ matrix.django-version }}"
run: pip install --pre "Django${{ matrix.django-version }}"
- name: Install tests
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'
run: pip install pytest 'pytest-asyncio==0.20.3' pytest-django 'injector>=0.19.0' django-ninja asgiref contextlib2 'ninja-schema>=0.13.4'
- name: Test
run: pytest
codestyle:
Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Django Ninja Extra - Class Based Utility and more for Django Ninja(Fast Django REST framework)"""

__version__ = "0.20.0"
__version__ = "0.20.2"

import django

Expand Down
10 changes: 6 additions & 4 deletions ninja_extra/security/http.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import logging
from abc import ABC, abstractmethod
from typing import Any, Optional

from django.conf import settings
from django.http import HttpRequest
from ninja.compatibility import get_headers
from ninja.security.http import DecodeError, HttpBasicAuth, HttpBearer, logger
from ninja.security.http import DecodeError, HttpBasicAuth, HttpBearer

logger = logging.getLogger("django")

__all__ = ["AsyncHttpBearer", "AsyncHttpBasicAuth"]


class AsyncHttpBearer(HttpBearer, ABC):
async def __call__(self, request: HttpRequest) -> Optional[Any]:
headers = get_headers(request)
headers = request.headers
auth_value = headers.get(self.header)
if not auth_value:
return None
Expand All @@ -31,7 +33,7 @@ async def authenticate(self, request: HttpRequest, token: str) -> Optional[Any]:

class AsyncHttpBasicAuth(HttpBasicAuth, ABC):
async def __call__(self, request: HttpRequest) -> Optional[Any]:
headers = get_headers(request)
headers = request.headers
auth_value = headers.get(self.header)
if not auth_value:
return None
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Framework :: Django",
"Framework :: Django :: 2.1",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: AsyncIO",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP",
]

requires = [
"Django >= 2.2",
"django-ninja==1.0.1",
"django-ninja==1.1.0",
"injector >= 0.19.0",
"asgiref",
"contextlib2"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_event_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ def test_get_event_works(self, path):
response = client.get(path.format(event_id=event.id))
assert response.status_code == 200
data = response.json()
event_schema = json.loads(EventSchema.from_orm(event).json())
event_schema = json.loads(EventSchema.from_orm(event).model_dump_json())
assert event_schema == data
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_default_model_config():
"paginator_kwargs": None,
"pagination_schema": PaginatedResponseSchema,
}
assert model_config.schema_config.dict() == {
assert model_config.schema_config.model_dump() == {
"include": "__all__",
"exclude": set(),
"optional": None,
Expand All @@ -60,7 +60,7 @@ def test_include_gen_schema():
assert model_config.create_schema is None
assert model_config.patch_schema is None
assert model_config.update_schema is None
assert model_config.retrieve_schema.schema() == {
assert model_config.retrieve_schema.model_json_schema() == {
"properties": {
"id": {"description": "", "title": "Id", "type": "integer"},
"title": {
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_exclude_gen_schema():
assert model_config.create_schema is None
assert model_config.patch_schema is None
assert model_config.update_schema is None
assert model_config.retrieve_schema.schema() == {
assert model_config.retrieve_schema.model_json_schema() == {
"properties": {
"id": {"description": "", "title": "Id", "type": "integer"},
"title": {
Expand Down