(3.0.0) cleaned up uv dependencies for pep 735, made a backwards incompatible change in the FloweryApiConfig model, and set up ruff formatting
Some checks failed
Actions / Build (push) Successful in 10s
Actions / Lint with Ruff & Pylint (push) Failing after 12s
Actions / Build Documentation (push) Failing after 6s

This commit is contained in:
cswimr 2024-11-15 00:10:38 -05:00
parent dcb5365fea
commit fde5dad155
Signed by: cswimr
GPG key ID: A9C162E867C851FA
11 changed files with 273 additions and 243 deletions

View file

@ -2,39 +2,40 @@ import asyncio
import logging
import sys
from pyflowery.models import FloweryAPIConfig
from pyflowery.pyflowery import FloweryAPI
from pyflowery import VERSION, FloweryAPI, FloweryAPIConfig
root = logging.getLogger()
root.setLevel(logging.DEBUG)
root.setLevel(level=logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setLevel(level=logging.DEBUG)
formatter = logging.Formatter(fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(fmt=formatter)
root.addHandler(hdlr=handler)
api = FloweryAPI(FloweryAPIConfig(user_agent="PyFloweryTests"))
api = FloweryAPI(config=FloweryAPIConfig(user_agent=f"PyFloweryTests/{VERSION}"))
ALEXANDER = "fa3ea565-121f-5efd-b4e9-59895c77df23" # TikTok
JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure
STORMTROOPER = "191c5adc-a092-5eea-b4ff-ce01f66153ae" # TikTok
ALEXANDER = "fa3ea565-121f-5efd-b4e9-59895c77df23" # TikTok
JACOB = "38f45366-68e8-5d39-b1ef-3fd4eeb61cdb" # Microsoft Azure
STORMTROOPER = "191c5adc-a092-5eea-b4ff-ce01f66153ae" # TikTok
async def test_fetch_tts():
async def test_fetch_tts() -> None:
"""Test the fetch_tts method"""
voice = api.get_voices(voice_id=ALEXANDER)[0]
tts = await api.fetch_tts(text="Sphinx of black quartz, judge my vow. The quick brown fox jumps over a lazy dog.", voice=voice)
try:
with open('test.mp3', 'wb') as f:
with open(file="test.mp3", mode="wb") as f:
f.write(tts)
except Exception as e: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except
api.config.logger.error(e, exc_info=True)
long_string = 'a' * 2049
long_string = "a" * 2049
try:
await api.fetch_tts(text=long_string)
except ValueError as e:
api.config.logger.error("This is expected to fail:\n%s", e, exc_info=True)
api.config.logger.error("This is expected to fail, and is not causing a non-zero exit code:\n%s", e, exc_info=True)
if __name__ == '__main__':
if __name__ == "__main__":
api.config.logger.info("testing fetch_tts")
asyncio.run(test_fetch_tts())
asyncio.run(main=test_fetch_tts())