Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ravachol-yang committed Mar 30, 2024
1 parent e93c140 commit 53f375b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
3 changes: 1 addition & 2 deletions app/models/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def _mix_up(self, len):
def generate(self, options=None):
name = uuid.uuid4().hex
# add prefix to file name
name_prefix = "/s-"

name_prefix = "/"
# set options
if options:
self.set_options(options)
Expand Down
10 changes: 3 additions & 7 deletions tests/audio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ def test_audio_generated():

def test_audio_noise():
audio = Audio()
assert isinstance(audio.generate(options = ['noise']), Audio)
assert isinstance(audio.generate(options = {"bool_options": True, "options":[False,True]}), Audio)

def test_audio_mix():
audio = Audio()
assert isinstance(audio.generate(options = ['noise', 'sine']), Audio)

def test_audio_wrong_options():
audio = Audio()
assert isinstance(audio.generate(options = ['aa']), Audio)
assert isinstance(audio.generate(options = {"bool_options": True, "options":[True,True]}), Audio)

def test_audio_empty_options():
audio = Audio()
assert isinstance(audio.generate(options = ['']), Audio)
assert isinstance(audio.generate(options = {"bool_options": False, "options": "aa"}), Audio)

def test_audio_to_mpeg():
audio = Audio()
Expand Down
10 changes: 5 additions & 5 deletions tests/text_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ def test_text_generated():

def test_text_options():
text = Text()
text.generate(options = ['zh','+en', '-d'])
text.generate(options = {"bool_options":True, "options":[True, True, True, False]})
assert isinstance(text.content(),str)

def test_text_option_only():
text = Text()
text.generate(options = ['en', ''])
assert isinstance(text.content(),str) and text.content().isascii()
text.generate(options = {"bool_options":True, "options":[False, False, False, True]})
assert isinstance(text.content(),str) and text.content().isdigit()

def test_text_wrong_options():
text = Text()
text.generate(options = ['aaa'])
text.generate(options = {"bool_options": True, "options":[True,False,True,False,False]})
assert isinstance(text.content(),str) and text.content().isascii()

def test_text_empty_options():
text = Text()
text.generate(options = [''])
text.generate(options = {"bool_options": False, "options": "aaa"})
assert isinstance(text.content(),str) and text.content().isascii()


Expand Down
2 changes: 1 addition & 1 deletion tests/voice_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def test_voice_generated():

def test_voice_noise():
voice = Voice()
assert isinstance(voice.generate(options = ['noise']).to_voice(), Voice)
assert isinstance(voice.generate(options = {"bool_options":True, "options": [False, True]}).to_voice(), Voice)

0 comments on commit 53f375b

Please sign in to comment.