Exemple #1
0
    def test_error_nested_message_set(self):
        message_set = cek.MessageSet(
            brief="title",
            verbose=["One Message",
                     cek.Message("Other Message", "en")])
        nested_message_set = cek.MessageSet(brief="title", verbose=message_set)

        with self.assertRaises(TypeError):
            clova.response(nested_message_set)
Exemple #2
0
    def test_response_message_set_verbose_list(self):
        message_set = cek.MessageSet(
            brief="title",
            verbose=["First Message",
                     cek.Message("Second Message", "en")])
        response = clova.response(message_set)
        output_speech = response['response']['outputSpeech']

        self.assertEqual(output_speech['type'], 'SpeechSet')
        self.assertEqual(output_speech['brief']['lang'], 'en')
        self.assertEqual(output_speech['brief']['type'], 'PlainText')
        self.assertEqual(output_speech['brief']['value'], 'title')

        self.assertEqual(output_speech['verbose']['type'], 'SpeechList')

        self.assertEqual(output_speech['verbose']['values'][0]['lang'], 'en')
        self.assertEqual(output_speech['verbose']['values'][0]['type'],
                         'PlainText')
        self.assertEqual(output_speech['verbose']['values'][0]['value'],
                         'First Message')

        self.assertEqual(output_speech['verbose']['values'][1]['lang'], 'en')
        self.assertEqual(output_speech['verbose']['values'][1]['type'],
                         'PlainText')
        self.assertEqual(output_speech['verbose']['values'][1]['value'],
                         'Second Message')
Exemple #3
0
    def test_response_message_set_verbose_simple(self):
        message_set = cek.MessageSet(brief="title",
                                     verbose="Simple detailed Message")
        response = clova.response(message_set)
        output_speech = response['response']['outputSpeech']

        self.assertEqual(output_speech['type'], 'SpeechSet')
        self.assertEqual(output_speech['brief']['lang'], 'en')
        self.assertEqual(output_speech['brief']['type'], 'PlainText')
        self.assertEqual(output_speech['brief']['value'], 'title')

        self.assertEqual(output_speech['verbose']['type'], 'SimpleSpeech')

        self.assertEqual(output_speech['verbose']['values']['lang'], 'en')
        self.assertEqual(output_speech['verbose']['values']['type'],
                         'PlainText')
        self.assertEqual(output_speech['verbose']['values']['value'],
                         'Simple detailed Message')
Exemple #4
0
def home_status_handler(clova_request):

    home_state = user_home_state.get(clova_request.user_id, HomeState())
    if home_state.is_aircon_on:
        aircon_state = "Air conditioner is turned on. "
    else:
        aircon_state = "Air conditioner is turned off. "

    if home_state.is_light_on:
        light_state = "Light is turned on. "
    else:
        light_state = "Light is turned off. "

    temperature = "Current room temperature is about {} degrees. ".format(home_state.currentTemperature)
    refrigerator = "Refrigerator contains {}. ".format(" and ".join(home_state.refrigerator))
    message = aircon_state + light_state + temperature + refrigerator

    message_set = cek.MessageSet(brief="Home is in good condition!", verbose=message)
    response = clova.response(message_set)
    return response