mirror of
https://github.com/dnlbauer/django-signposting.git
synced 2026-09-10 14:05:31 +00:00
linting
This commit is contained in:
3
.flake8
Normal file
3
.flake8
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[flake8]
|
||||||
|
max-line-length = 99
|
||||||
|
exclude = .git, __pycache__, .pytest_cache, .venv, venv, build
|
||||||
@@ -36,4 +36,3 @@ class SignpostingMiddleware:
|
|||||||
link_snippets[-1] += f' ; type="{signpost.type}"'
|
link_snippets[-1] += f' ; type="{signpost.type}"'
|
||||||
|
|
||||||
response["Link"] = " , ".join(link_snippets)
|
response["Link"] = " , ".join(link_snippets)
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ def add_signposts(response: HttpResponse, *args: Signpost):
|
|||||||
response._signposts = []
|
response._signposts = []
|
||||||
|
|
||||||
for signpost in args:
|
for signpost in args:
|
||||||
if not signpost in response._signposts:
|
if signpost not in response._signposts:
|
||||||
response._signposts.append(signpost)
|
response._signposts.append(signpost)
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ from django_signposting.utils import add_signposts
|
|||||||
|
|
||||||
from signposting import Signpost, LinkRel
|
from signposting import Signpost, LinkRel
|
||||||
|
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
response = HttpResponse("Hello, world!")
|
response = HttpResponse("Hello, world!")
|
||||||
|
|
||||||
# Add signpostings as string
|
# Add signpostings as string
|
||||||
add_signposts(
|
add_signposts(
|
||||||
response,
|
response,
|
||||||
@@ -13,4 +14,4 @@ def my_view(request):
|
|||||||
Signpost(LinkRel.author, "https://orcid.org/0000-0001-9447-460X")
|
Signpost(LinkRel.author, "https://orcid.org/0000-0001-9447-460X")
|
||||||
)
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ dev = [
|
|||||||
[pytest]
|
[pytest]
|
||||||
minversion = 6.0
|
minversion = 6.0
|
||||||
addopts = "-ra -q"
|
addopts = "-ra -q"
|
||||||
testpaths = ["tests"]
|
testpaths = ["tests"]
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import pytest
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from re import A
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django_signposting.middleware import SignpostingMiddleware
|
from django_signposting.middleware import SignpostingMiddleware
|
||||||
from signposting import LinkRel, Signpost
|
from signposting import LinkRel, Signpost
|
||||||
|
|
||||||
|
|
||||||
def test_middleware_no_signposting():
|
def test_middleware_no_signposting():
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
response.status_code = 200
|
response.status_code = 200
|
||||||
@@ -74,4 +74,4 @@ def test_middleware_type_link():
|
|||||||
|
|
||||||
middleware = SignpostingMiddleware(lambda request: response)
|
middleware = SignpostingMiddleware(lambda request: response)
|
||||||
response = middleware(None)
|
response = middleware(None)
|
||||||
assert response.headers["Link"] == '<http://schema.org/Dataset> ; rel="type"'
|
assert response.headers["Link"] == '<http://schema.org/Dataset> ; rel="type"'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from signposting import Signpost, LinkRel
|
|||||||
|
|
||||||
def test_add_signpost():
|
def test_add_signpost():
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
add_signposts(response, Signpost(LinkRel.item,"http://example.com"))
|
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
||||||
|
|
||||||
assert len(response._signposts) == 1
|
assert len(response._signposts) == 1
|
||||||
|
|
||||||
@@ -18,7 +18,6 @@ def test_add_multiple_signposts():
|
|||||||
Signpost(LinkRel.author, "https://example3.com"),
|
Signpost(LinkRel.author, "https://example3.com"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
assert len(response._signposts) == 3
|
assert len(response._signposts) == 3
|
||||||
|
|
||||||
|
|
||||||
@@ -35,4 +34,4 @@ def test_add_signpost_duplicate():
|
|||||||
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
||||||
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
||||||
|
|
||||||
assert len(response._signposts) == 1
|
assert len(response._signposts) == 1
|
||||||
|
|||||||
Reference in New Issue
Block a user