File size: 3,248 Bytes
12f4772
 
 
 
 
1a63d97
12f4772
 
 
 
1a63d97
12f4772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()