Ejemplo n.º 1
0
    def intentRequest(self):
        self.ask('deviceName')

        card = TextCard('您要查找什么智能设备呢? 比如"查找我的空调"')
        card.add_cue_words("百度")
        card.add_cue_words("百度")
        card.add_cue_words("百度")
        card.set_anchor("http://www.baidu.com", "百度")
        return {
            'card': card,
            'outputSpeech': '<speak>您要查找什么智能设备呢? 比如"查找我的空调"</speak>'
        }
Ejemplo n.º 2
0
class TextCardTest(unittest.TestCase):
    '''
    TextCard单元测试
    '''
    def setUp(self):
        self.card = TextCard('这是TextCard')

    def testAddCueWords(self):
        '''
        测试添加关键字
        :return:
        '''
        self.card.add_cue_words(['cuewords1', 'cuewords2'])
        card = {
            'type': 'txt',
            'content': '这是TextCard',
            'cueWords': ['cuewords1', 'cuewords2']
        }
        self.assertEquals(self.card.get_data(), card)

    def testSetAnchor(self):
        '''
        测试setAnchor方法
        :return:
        '''
        self.card.set_anchor('http://www.baidu.com', '百度')
        card = {
            'type': 'txt',
            'content': '这是TextCard',
            'url': 'http://www.baidu.com',
            'anchorText': '百度'
        }
        self.assertEquals(self.card.get_data(), card)

    def testGetData(self):
        '''
        测试getData方法
        :return:
        '''
        card = {
            'type': 'txt',
            'content': '这是TextCard',
        }
        self.assertEquals(self.card.get_data(), card)

    pass