Skip to content

Commit e2aa694

Browse files
committed
feat: Add audio testing functionality
fix: Update test cases for image generation API patch: Skip tests when PYTGPT_TEST_AUDIO is not set
1 parent 7c870e7 commit e2aa694

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unittest
23
from fastapi.testclient import TestClient
34
from fastapi import status
@@ -70,6 +71,10 @@ def test_text_stream(self):
7071
)
7172
self.assertTrue(resp.is_success)
7273

74+
@unittest.skipUnless(
75+
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
76+
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
77+
)
7378
def test_prompt_to_image_post(self):
7479
resp = self.client.post(
7580
"/v1/image",
@@ -84,18 +89,30 @@ def test_prompt_to_image_post(self):
8489
self.assertIsNotNone(resp_dict.get("urls"))
8590
self.assertEqual(len(resp_dict["urls"]), 2)
8691

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

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

112+
@unittest.skipUnless(
113+
os.getenv('PYTGPT_TEST_AUDIO', '') == "true",
114+
"PYTGPT_TEST_AUDIO environment variable is not set to 'true' "
115+
)
99116
def test_prompt_to_image_bytes_get_redirect(self):
100117
resp = self.client.get(
101118
"/v1/image/bytes",

0 commit comments

Comments
 (0)