project_charles / tests /test_streaming_chat_service.py
sohojoe's picture
refactor
1a63d97
raw
history blame
3.25 kB
import unittest
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from chat_service import ChatService
class TestShouldWeSendToVoice(unittest.TestCase):
def setUp(self):
self.chat_service = ChatService()
def test_should_we_send_to_voice(self):
test_cases = [
('This is a simple sentence.', None),
('This is a simple sentence?', None),
('This is a simple sentence!', None),
('This is a simple sentence. ', 'This is a simple sentence.'),
('This is a simple sentence? ', 'This is a simple sentence?'),
('This is a simple sentence! ', 'This is a simple sentence!'),
('This is a simple sentence; ', None),
('This is a simple sentence: ', None),
('This sentence contains a quote: "Hello, world!".', None),
('This sentence contains a quote: "Hello, world!"..', None),
('This sentence contains a quote: "Hello, world!"...', None),
('This sentence contains a quote: "Hello, world!". ', 'This sentence contains a quote: "Hello, world!".'),
('This sentence contains a quote: "Hello, world!".\n', 'This sentence contains a quote: "Hello, world!".'),
('This sentence contains a quote with a question: "How are you?"', None),
('This sentence contains a quote with a question: "How are you?" Hello', 'This sentence contains a quote with a question: "How are you?"'),
('This sentence has nested quotes: "She said, \'Hello, world!\'".', None),
('This sentence has nested quotes: "She said, \'Hello, world!\'". Hello', 'This sentence has nested quotes: "She said, \'Hello, world!\'".'),
('This sentence has nested parentheses: (This is (a test).)', None),
('This sentence has nested parentheses: (This is (a test).) Hello', 'This sentence has nested parentheses: (This is (a test).)'),
('This sentence has nested brackets: [This is [a test].]', None),
('This sentence has nested brackets: [This is [a test].] Hello', 'This sentence has nested brackets: [This is [a test].]'),
('This sentence has multiple consecutive termination characters: "What!?".', None),
('This sentence has multiple consecutive termination characters: "What!?". ', 'This sentence has multiple consecutive termination characters: "What!?".'),
('This sentence has multiple consecutive termination characters and a quote: "What!?"', None),
('This sentence has multiple consecutive termination characters and a quote: "What!?" ', 'This sentence has multiple consecutive termination characters and a quote: "What!?"'),
('This sentence has multiple consecutive termination characters and a quote: "What!?" H', 'This sentence has multiple consecutive termination characters and a quote: "What!?"'),
]
for sentence, expected_output in test_cases:
with self.subTest(sentence=sentence):
actual_output = self.chat_service._should_we_send_to_voice(sentence)
self.assertEqual(actual_output, expected_output)
if __name__ == '__main__':
unittest.main()