Example #1
0
def test_parse_payload_json(rf):
    request = rf.post(
        "/payload", content_type="application/json", data=json.dumps(H_ENTRY)
    )
    view = micropub_views.Micropub()
    payload = view.parse_payload(request)
    assert payload == H_ENTRY
Example #2
0
def test_micropub_decode_formdat():
    post = QueryDict("h=entry&content=hi+there&slug=hi&tags[]=a&tags[]=b&tags[]=c")
    v = micropub_views.Micropub()
    decoded = v.decode_formdata(post)
    assert decoded["type"] == ["h-entry"]
    assert decoded["properties"]["content"] == ["hi there"]
    assert decoded["properties"]["slug"] == ["hi"]
    assert decoded["properties"]["tags"] == ["a", "b", "c"]
Example #3
0
def test_construct_entry_no_title(rf):
    request = rf.post(
        "/payload", content_type="application/json", data=json.dumps(H_ENTRY_NO_NAME)
    )
    view = micropub_views.Micropub()
    payload = view.parse_payload(request)
    entry = view.construct_entry(payload)
    assert entry.title == ""
    assert entry.slug == H_ENTRY_NO_NAME["properties"]["mp-slug"][0]
    assert entry.body == "<p>" + H_ENTRY_NO_NAME["properties"]["content"][0] + "</p>"