adf0d17497
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
from gradio.image_utils import extract_svg_content
|
|
|
|
|
|
def test_extract_svg_content_local_file():
|
|
svg_path = "test/test_files/file_icon.svg"
|
|
svg_content = extract_svg_content(svg_path)
|
|
assert (
|
|
svg_content
|
|
== '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"><path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline></svg>'
|
|
)
|
|
|
|
|
|
def test_extract_svg_content_from_url(monkeypatch):
|
|
class MockResponse:
|
|
def __init__(self):
|
|
self.text = "<svg>mock svg content</svg>"
|
|
|
|
def raise_for_status(self):
|
|
pass
|
|
|
|
async def mock_get(*args, **kwargs):
|
|
return MockResponse()
|
|
|
|
# extract_svg_content now routes through the SSRF-protected helper rather
|
|
# than calling httpx.get directly, so patch that instead.
|
|
monkeypatch.setattr("gradio.processing_utils.async_ssrf_protected_get", mock_get)
|
|
svg_content = extract_svg_content("https://example.com/test.svg")
|
|
assert svg_content == "<svg>mock svg content</svg>"
|