Exemplo n.º 1
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('pong', 'pod', 'john', language='en-US')

        expect(m).to.be.a(Pong)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.language).to.equal('en-US')
Exemplo n.º 2
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('done', 'pod', 'john', require_input=True)

        expect(m).to.be.a(Done)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.require_input).to.be.true
Exemplo n.º 3
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('context', 'pod', 'john', context='new_context')

        expect(m).to.be.a(Context)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.context).to.equal('new_context')
Exemplo n.º 4
0
 def test_it_should_expose_the_list_of_available_messages(self):
     names = Message.available()
     expect(names).to.equal([
         'ping',
         'pong',
         'parse',
         'answer',
         'ask',
         'context',
         'done',
         'thinking',
     ])
Exemplo n.º 5
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('parse',
                              'pod',
                              'john',
                              text='Turn the lights on',
                              meta={'a_meta': 5})

        expect(m).to.be.a(Parse)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.text).to.equal('Turn the lights on')
        expect(m.meta).to.equal({
            'a_meta': 5,
        })
Exemplo n.º 6
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('ask',
                              'pod',
                              'john',
                              language='en-US',
                              slot='room',
                              text='Which rooms?',
                              choices=[],
                              meta={'a_meta': 5})

        expect(m).to.be.an(Ask)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.language).to.equal('en-US')
        expect(m.slot).to.equal('room')
        expect(m.text).to.equal('Which rooms?')
        expect(m.choices).to.be.empty
        expect(m.meta).to.equal({
            'a_meta': 5,
        })
Exemplo n.º 7
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('answer',
                              'pod',
                              'john',
                              language='en-US',
                              text='This is a message',
                              cards=[{
                                  'header': 'Card title',
                                  'header_link': None,
                                  'media': None,
                                  'raw_header': 'Card title',
                                  'raw_subhead': None,
                                  'raw_text': 'Card content text',
                                  'subhead': None,
                                  'text': 'Card content text',
                              }],
                              meta={
                                  'a_meta': 5,
                                  'another_one': 66
                              })

        expect(m).to.be.an(Answer)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')
        expect(m.language).to.equal('en-US')
        expect(m.text).to.equal('This is a message')
        expect(m.cards).to.equal([{
            'header': 'Card title',
            'header_link': None,
            'media': None,
            'raw_header': 'Card title',
            'raw_subhead': None,
            'raw_text': 'Card content text',
            'subhead': None,
            'text': 'Card content text',
        }])
        expect(m.meta).to.equal({
            'a_meta': 5,
            'another_one': 66,
        })
Exemplo n.º 8
0
    def test_it_should_be_deserializable(self):
        m = Message.from_data('thinking', 'pod', 'john')

        expect(m).to.be.a(Thinking)
        expect(m.device_identifier).to.equal('pod')
        expect(m.user_identifier).to.equal('john')