diff --git a/assets/testing.stl b/assets/testing.stl new file mode 100644 index 000000000..07c9bf8b7 Binary files /dev/null and b/assets/testing.stl differ diff --git a/kittycad/api/file/file_convert_with_base64_helper.py b/kittycad/api/file/file_convert_with_base64_helper.py index fa4c59615..e39f9226c 100644 --- a/kittycad/api/file/file_convert_with_base64_helper.py +++ b/kittycad/api/file/file_convert_with_base64_helper.py @@ -27,7 +27,7 @@ def sync( client=client, ) - if fc.output != "": + if fc != None and fc.output != "": fc.output = base64.b64decode(fc.output) return fc @@ -51,7 +51,7 @@ async def asyncio( client=client, ) - if fc.output != "": + if fc != None and fc.output != "": fc.output = base64.b64decode(fc.output) return fc diff --git a/kittycad/client_test.py b/kittycad/client_test.py index 059138ff7..4a3593105 100644 --- a/kittycad/client_test.py +++ b/kittycad/client_test.py @@ -1,3 +1,4 @@ +import os import pytest import asyncio @@ -74,3 +75,36 @@ async def test_ping_async(): assert message != None print(f"Message: {message}") + +def test_file_convert_stl(): + # Create our client. + client = AuthenticatedClientFromEnv() + + dir_path = os.path.dirname(os.path.realpath(__file__)) + file = open(os.path.join(dir_path, "../assets/testing.stl"), "rb") + content = file.read() + file.close() + + # Get the fc. + fc: FileConversion = file_convert_with_base64_helper.sync(client=client, content=content, source_format=ValidFileTypes.STL, output_format=ValidFileTypes.OBJ) + + assert fc != None + + print(f"FileConversion: {fc}") + +@pytest.mark.asyncio +async def test_file_convert_stl_async(): + # Create our client. + client = AuthenticatedClientFromEnv() + + dir_path = os.path.dirname(os.path.realpath(__file__)) + file = open(os.path.join(dir_path, "../assets/testing.stl"), "rb") + content = file.read() + file.close() + + # Get the fc. + fc: FileConversion = await file_convert_with_base64_helper.asyncio(client=client, content=content, source_format=ValidFileTypes.STL, output_format=ValidFileTypes.OBJ) + + assert fc != None + + print(f"FileConversion: {fc}")