2021-12-15 08:33:25 -08:00
|
|
|
import os
|
2021-12-15 06:49:45 -08:00
|
|
|
import pytest
|
|
|
|
import asyncio
|
|
|
|
|
2022-02-27 22:24:39 -08:00
|
|
|
from .client import ClientFromEnv
|
2022-04-06 21:14:12 -07:00
|
|
|
from .models import FileConversion, FileConversionOutputFormat, FileConversionSourceFormat, User, Pong, FileConversionStatus
|
|
|
|
from .api.file import create_file_conversion_with_base64_helper
|
|
|
|
from .api.meta import ping
|
|
|
|
from .api.users import get_user_self
|
2021-12-15 06:42:39 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 06:42:39 -08:00
|
|
|
def test_get_session():
|
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 06:42:39 -08:00
|
|
|
|
|
|
|
# Get the session.
|
2022-04-06 21:14:12 -07:00
|
|
|
session: User = get_user_self.sync(client=client)
|
2021-12-15 06:42:39 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert session is not None
|
2021-12-15 06:56:56 -08:00
|
|
|
|
2021-12-15 06:42:39 -08:00
|
|
|
print(f"Session: {session}")
|
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 06:49:45 -08:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_get_session_async():
|
2021-12-15 06:42:39 -08:00
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 06:42:39 -08:00
|
|
|
|
|
|
|
# Get the session.
|
2022-04-06 21:14:12 -07:00
|
|
|
session: User = await get_user_self.asyncio(client=client)
|
2021-12-15 06:56:56 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert session is not None
|
2021-12-15 06:42:39 -08:00
|
|
|
|
|
|
|
print(f"Session: {session}")
|
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 06:58:54 -08:00
|
|
|
def test_ping():
|
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 06:58:54 -08:00
|
|
|
|
|
|
|
# Get the message.
|
2022-04-06 21:14:12 -07:00
|
|
|
message: Pong = ping.sync(client=client)
|
2021-12-15 06:58:54 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert message is not None
|
2021-12-15 06:58:54 -08:00
|
|
|
|
|
|
|
print(f"Message: {message}")
|
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 06:58:54 -08:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_ping_async():
|
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 06:58:54 -08:00
|
|
|
|
|
|
|
# Get the message.
|
2022-04-06 21:14:12 -07:00
|
|
|
message: Pong = await ping.asyncio(client=client)
|
2021-12-15 06:58:54 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert message is not None
|
2021-12-15 06:58:54 -08:00
|
|
|
|
|
|
|
print(f"Message: {message}")
|
2021-12-15 08:33:25 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 08:33:25 -08:00
|
|
|
def test_file_convert_stl():
|
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 08:33:25 -08:00
|
|
|
|
|
|
|
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.
|
2022-04-06 21:14:12 -07:00
|
|
|
fc: FileConversion = create_file_conversion_with_base64_helper.sync(
|
2022-02-27 21:48:39 -08:00
|
|
|
client=client,
|
2022-02-27 22:30:43 -08:00
|
|
|
body=content,
|
2022-04-06 21:14:12 -07:00
|
|
|
src_format=FileConversionSourceFormat.STL,
|
|
|
|
output_format=FileConversionOutputFormat.OBJ)
|
2021-12-15 08:33:25 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert fc is not None
|
2021-12-15 08:33:25 -08:00
|
|
|
|
|
|
|
print(f"FileConversion: {fc}")
|
|
|
|
|
2022-03-06 17:46:14 -08:00
|
|
|
assert fc.id is not None
|
|
|
|
|
|
|
|
assert fc.status == FileConversionStatus.COMPLETED
|
|
|
|
|
|
|
|
print(f"FileConversion: {fc}")
|
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
|
2021-12-15 08:33:25 -08:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_file_convert_stl_async():
|
|
|
|
# Create our client.
|
2022-02-27 18:39:04 -08:00
|
|
|
client = ClientFromEnv()
|
2021-12-15 08:33:25 -08:00
|
|
|
|
|
|
|
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.
|
2022-04-06 21:14:12 -07:00
|
|
|
fc: FileConversion = await create_file_conversion_with_base64_helper.asyncio(client=client, body=content, src_format=FileConversionSourceFormat.STL, output_format=FileConversionOutputFormat.OBJ)
|
2021-12-15 08:33:25 -08:00
|
|
|
|
2022-02-27 21:48:39 -08:00
|
|
|
assert fc is not None
|
2021-12-15 08:33:25 -08:00
|
|
|
|
|
|
|
print(f"FileConversion: {fc}")
|
2022-03-06 17:46:14 -08:00
|
|
|
|
|
|
|
assert fc.id is not None
|
|
|
|
|
|
|
|
print(f"FileConversion: {fc}")
|