def test_wrong_language(self):
        # Tets builders
        for lang in ["es", "jp"]:
            with self.assertRaises(ValueError):
                cek.ResponseBuilder(default_language=lang)
            with self.assertRaises(ValueError):
                cek.SpeechBuilder(default_language=lang)

        speech_builder = cek.SpeechBuilder("ja")
        response_builder = cek.ResponseBuilder("ja")
        # Test builder methods
        with self.assertRaises(ValueError):
            speech_builder.plain_text("Hola", language="es")
        with self.assertRaises(ValueError):
            response_builder.simple_speech_text("Hola", language="es")
    def test_default_language(self):
        ja_builder = cek.ResponseBuilder(default_language="ja")
        en_builder = cek.ResponseBuilder(default_language="en")
        response_japanese = ja_builder.simple_speech_text(message="日本語")
        response_english = en_builder.simple_speech_text(message="English")
        # explicit language arg
        response_japanese2x = en_builder.simple_speech_text(message="日本語",
                                                            language="ja")

        japanese = response_japanese['response']['outputSpeech']['values'][
            'lang']
        japanese2x = response_japanese2x['response']['outputSpeech']['values'][
            'lang']
        english = response_english['response']['outputSpeech']['values'][
            'lang']

        self.assertEqual(japanese, 'ja')
        self.assertEqual(japanese2x, 'ja')
        self.assertEqual(english, 'en')
#   https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import unittest
import cek
import json

from data.requests import LAUNCH_REQUEST_BODY, INTENT_REQUEST_BODY, END_REQUEST_BODY, DEFAULT_REQUEST_BODY, GUIDE_REQUEST_BODY, NO_REQUEST_BODY

speech_builder = cek.SpeechBuilder(default_language="en")
response_builder = cek.ResponseBuilder(default_language="en")
clova_handler = cek.RequestHandler(application_id="com.line.myApplication",
                                   debug_mode=True)
mocked_header = {"": ""}


@clova_handler.launch
def launch_request_handler(clova_request):
    return response_builder.simple_speech_text("Hello! Welcome to My Service!")


@clova_handler.intent("TurnOn")
def turn_on_handler(clova_request):
    response = response_builder.simple_speech_text("Turned on Something")
    plain_text = speech_builder.plain_text("Reprompt Message.")
    response.reprompt = speech_builder.simple_speech(plain_text)
Beispiel #4
0
def advise_handler(clova_request):
    response_builder = cek.ResponseBuilder(default_language="ja")
    return response_builder.simple_speech_text(message="じゃあ測り終わったら, また 呼んで ね",
                                               language="ja")