Files
kittycad.py/kittycad/client_test.py
Jess Frazelle 7c4321306a fixups
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2022-06-11 17:59:55 -07:00

109 lines
2.5 KiB
Python

import os
import pytest
import asyncio
from .client import ClientFromEnv
from .models import FileConversion, FileOutputFormat, FileSourceFormat, User, Pong, APICallStatus
from .api.file import create_file_conversion_with_base64_helper
from .api.meta import ping
from .api.users import get_user_self
def test_get_session():
# Create our client.
client = ClientFromEnv()
# Get the session.
session: User = get_user_self.sync(client=client)
assert session is not None
print(f"Session: {session}")
@pytest.mark.asyncio
async def test_get_session_async():
# Create our client.
client = ClientFromEnv()
# Get the session.
session: User = await get_user_self.asyncio(client=client)
assert session is not None
print(f"Session: {session}")
def test_ping():
# Create our client.
client = ClientFromEnv()
# Get the message.
message: Pong = ping.sync(client=client)
assert message is not None
print(f"Message: {message}")
@pytest.mark.asyncio
async def test_ping_async():
# Create our client.
client = ClientFromEnv()
# Get the message.
message: Pong = await ping.asyncio(client=client)
assert message is not None
print(f"Message: {message}")
def test_file_convert_stl():
# Create our client.
client = ClientFromEnv()
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 = create_file_conversion_with_base64_helper.sync(
client=client,
body=content,
src_format=FileSourceFormat.STL,
output_format=FileOutputFormat.OBJ)
assert fc is not None
print(f"FileConversion: {fc}")
assert fc.id is not None
assert fc.status == APICallStatus.COMPLETED
print(f"FileConversion: {fc}")
@pytest.mark.asyncio
async def test_file_convert_stl_async():
# Create our client.
client = ClientFromEnv()
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 create_file_conversion_with_base64_helper.asyncio(client=client, body=content, src_format=FileSourceFormat.STL, output_format=FileOutputFormat.OBJ)
assert fc is not None
print(f"FileConversion: {fc}")
assert fc.id is not None
print(f"FileConversion: {fc}")