Skip to content

Commit

Permalink
tests: typing (#190)
Browse files Browse the repository at this point in the history
tests typing
  • Loading branch information
chamini2 authored Apr 26, 2024
1 parent 2bdddd4 commit c79a3d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions projects/fal/tests/toolkit/file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_binary_content_matches():
def test_default_content_type():
file = File.from_bytes(b"Hello World", repository="in_memory")
assert file.content_type == "application/octet-stream"
assert file.file_name
assert file.file_name.endswith(".bin")


Expand All @@ -27,6 +28,7 @@ def test_file_name_from_content_type():
b"Hello World", content_type="text/plain", repository="in_memory"
)
assert file.content_type == "text/plain"
assert file.file_name
assert file.file_name.endswith(".txt")


Expand Down
11 changes: 10 additions & 1 deletion projects/fal/tests/toolkit/image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from base64 import b64encode
from io import BytesIO
from typing import Literal, overload

import pytest
from PIL import Image as PILImage
Expand All @@ -10,6 +11,14 @@
from fal.toolkit import Image


@overload
def get_image(as_bytes: Literal[False] = False) -> PILImage.Image: ...


@overload
def get_image(as_bytes: Literal[True]) -> bytes: ...


def get_image(as_bytes: bool = False):
from PIL import Image

Expand Down Expand Up @@ -123,7 +132,7 @@ def init_image_on_fal(input: TestInput) -> bytes:
pil_image = input_image.to_pil()
return pil_image_to_bytes(pil_image)

test_input = TestInput(image=image_to_data_uri(get_image()))
test_input = TestInput(image=Image.from_pil(get_image()))
image_bytes = init_image_on_fal(test_input)

assert image_bytes == get_image(as_bytes=True)

0 comments on commit c79a3d6

Please sign in to comment.