mirror of
https://github.com/dnlbauer/django-signposting.git
synced 2026-09-10 22:15:30 +00:00
use signposting package
This commit is contained in:
@@ -1,47 +1,38 @@
|
||||
from django.http import HttpResponse
|
||||
from django_signposting.utils import add_signposts
|
||||
from signposting import Signpost, LinkRel
|
||||
|
||||
|
||||
def test_add_signpost():
|
||||
response = HttpResponse()
|
||||
add_signposts(response, item="http://example.com")
|
||||
add_signposts(response, Signpost(LinkRel.item,"http://example.com"))
|
||||
|
||||
assert response._signposts["item"] == ["http://example.com"]
|
||||
assert len(response._signposts) == 1
|
||||
|
||||
|
||||
def test_add_multiple_signposts():
|
||||
response = HttpResponse()
|
||||
add_signposts(response,
|
||||
item="http://example.com",
|
||||
author=["https://example2.com", "https://example3.com"]
|
||||
Signpost(LinkRel.item, "http://example.com"),
|
||||
Signpost(LinkRel.author, "https://example2.com"),
|
||||
Signpost(LinkRel.author, "https://example3.com"),
|
||||
)
|
||||
|
||||
assert response._signposts == {
|
||||
"item": ["http://example.com"],
|
||||
"author": [
|
||||
"https://example2.com",
|
||||
"https://example3.com",
|
||||
]
|
||||
}
|
||||
|
||||
assert len(response._signposts) == 3
|
||||
|
||||
|
||||
def test_add_signposts_with_content_type():
|
||||
def test_add_signpost_call_multiple_times():
|
||||
response = HttpResponse()
|
||||
add_signposts(response,
|
||||
item=("http://example.com", "text/json"),
|
||||
author=["https://example2.com", "https://example3.com"]
|
||||
)
|
||||
add_signposts(response, Signpost(LinkRel.item, "http://example.com"))
|
||||
add_signposts(response, Signpost(LinkRel.item, "http://example2.com"))
|
||||
|
||||
assert response._signposts == {
|
||||
"item": [("http://example.com", "text/json")],
|
||||
"author": [
|
||||
"https://example2.com",
|
||||
"https://example3.com",
|
||||
]
|
||||
}
|
||||
assert len(response._signposts) == 2
|
||||
|
||||
|
||||
def test_add_signposts_from_dict():
|
||||
def test_add_signpost_duplicate():
|
||||
response = HttpResponse()
|
||||
add_signposts(response, **{"cite-as": ["https://example.com"]})
|
||||
assert response._signposts["cite-as"] == ["https://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
|
||||
Reference in New Issue
Block a user