Skip to content

Commit

Permalink
feat: Add audio testing functionality
Browse files Browse the repository at this point in the history
fix: Update test cases for image generation API
patch: Skip tests when PYTGPT_TEST_AUDIO is not set
  • Loading branch information
Simatwa committed Nov 10, 2024
1 parent 7c870e7 commit e2aa694
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import unittest
from fastapi.testclient import TestClient
from fastapi import status
Expand Down Expand Up @@ -70,6 +71,10 @@ def test_text_stream(self):
)
self.assertTrue(resp.is_success)

@unittest.skipUnless(
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
)
def test_prompt_to_image_post(self):
resp = self.client.post(
"/v1/image",
Expand All @@ -84,18 +89,30 @@ def test_prompt_to_image_post(self):
self.assertIsNotNone(resp_dict.get("urls"))
self.assertEqual(len(resp_dict["urls"]), 2)

@unittest.skipUnless(
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
)
def test_prompt_to_image_bytes_post(self):
resp = self.client.post(
"/v1/image/bytes", json={"prompt": "Jay Z performing", "timeout": 30}
)
self.assertIsNotNone(resp.headers.get("Content-Disposition"))

@unittest.skipUnless(
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
)
def test_prompt_to_image_bytes_get(self):
resp = self.client.get(
"/v1/image/bytes", params={"prompt": "Jay Z performing", "timeout": 30}
)
self.assertIsNotNone(resp.headers.get("Content-Disposition"))

@unittest.skipUnless(
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
)
def test_prompt_to_image_bytes_get_redirect(self):
resp = self.client.get(
"/v1/image/bytes",
Expand Down

0 comments on commit e2aa694

Please sign in to comment.