-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1854 from roland-ruedenauer/fix_download_binary_data
Fix download link for binary content (missing namespace)
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright: 2025 MoinMoin | ||
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details. | ||
|
||
""" | ||
MoinMoin - Tests for moin.converters.everything | ||
""" | ||
|
||
import pytest | ||
|
||
from . import serialize, XMLNS_RE | ||
|
||
from moin.constants.keys import CONTENTTYPE, ITEMTYPE, REV_NUMBER | ||
from moin.converters.everything import Converter | ||
from moin.items.content import Content | ||
|
||
from moin.utils.interwiki import split_fqname | ||
|
||
from moin.items import Item | ||
from moin.utils.tree import moin_page, xlink, html, xinclude | ||
|
||
from unittest.mock import Mock | ||
|
||
namespaces = {moin_page: "", xlink: "xlink", html: "xhtml", xinclude: "xinclude"} | ||
|
||
meta = {CONTENTTYPE: "binary/blob", ITEMTYPE: "default", REV_NUMBER: 1} | ||
|
||
output_re = XMLNS_RE | ||
|
||
|
||
def serialize_strip(elem, **options): | ||
result = serialize(elem, namespaces=namespaces, **options) | ||
return output_re.sub("", result) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input,output", | ||
[ | ||
( | ||
"machines/nuc/fw2.blob", | ||
'<page><body><a xlink:href="wiki:///machines/nuc/fw2.blob?do=get&rev=691da3aa1dd146d296bcd9ac92b25be5">Download machines/nuc/fw2.blob.</a></body></page>', | ||
) | ||
], | ||
) | ||
def test_conv(input, output): | ||
rev = Mock() | ||
rev.meta = meta | ||
rev.revid = "691da3aa1dd146d296bcd9ac92b25be5" | ||
rev.item = Item(split_fqname(input), rev=rev, content=Content.create(meta[CONTENTTYPE])) | ||
conv = Converter() | ||
out = conv(rev, rev.item.contenttype) | ||
assert serialize_strip(out) == output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters