stages/prompt: fix tests for file field
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
de26c65fa0
commit
277df4f04f
|
@ -1,6 +1,6 @@
|
|||
"""prompt models"""
|
||||
from typing import Any, Optional
|
||||
from urllib.parse import urlparse
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
from uuid import uuid4
|
||||
|
||||
from django.db import models
|
||||
|
@ -89,7 +89,7 @@ class InlineFileField(CharField):
|
|||
_mime, _, enc = header.partition(";")
|
||||
if enc != "base64":
|
||||
raise ValidationError("Invalid encoding")
|
||||
return super().to_internal_value(uri)
|
||||
return super().to_internal_value(urlunparse(uri))
|
||||
|
||||
|
||||
class Prompt(SerializerModel):
|
||||
|
|
|
@ -118,11 +118,11 @@ class TestPromptStage(FlowTestCase):
|
|||
InlineFileField().to_internal_value("data:foo/bar;foo,qwer")
|
||||
self.assertEqual(
|
||||
InlineFileField().to_internal_value("data:mine/type;base64,Zm9v"),
|
||||
"foo",
|
||||
"data:mine/type;base64,Zm9v",
|
||||
)
|
||||
self.assertEqual(
|
||||
InlineFileField().to_internal_value("data:mine/type;base64,Zm9vqwer"),
|
||||
"Zm9vqwer",
|
||||
"data:mine/type;base64,Zm9vqwer",
|
||||
)
|
||||
|
||||
def test_render(self):
|
||||
|
|
Reference in a new issue