Example #1
0
 def test_with_update_attributes(self):
     say = Say(self.text)
     text = 'Now I will not stop talking'
     voice = Voice.MALE
     say.text = text
     say.voice = voice
     expected = '<Say voice="%s">%s</Say>' % (voice.value, text)
     assert say.xml == expected
Example #2
0
 def test_init_add_element(self):
     text = 'Hello from Avaya CPaaS!'
     say = Say(text)
     gather = Gather()
     gather.addElement(say)
     expected = '<Gather><Say>%s</Say></Gather>' % text
     assert gather.xml == expected
Example #3
0
 def test_init_add_element(self):
     text = 'Hello from Zang!'
     say = Say(text)
     gather = Gather()
     gather.addElement(say)
     expected = '<Gather input="dtmf"><Say>%s</Say></Gather>' % text
     assert gather.xml == expected
Example #4
0
 def test_remove_element_at_out_of_range_index(self):
     text = 'Hello from Zang!'
     say = Say(text)
     response = Response()
     response.addElement(say)
     index = len(response._content)
     self.assertRaises(
         IndexError, lambda: response.removeElementAtIndex(index))
Example #5
0
 def test_remove_element_at_out_of_range_index(self):
     text = 'Hello from Avaya CPaaS!'
     say = Say(text)
     gather = Gather()
     gather.addElement(say)
     index = len(gather._content)
     self.assertRaises(IndexError,
                       lambda: gather.removeElementAtIndex(index))
Example #6
0
 def test_init_remove_element_at_index(self):
     text = 'Hello from Avaya CPaaS!'
     say = Say(text)
     gather = Gather()
     gather.addElement(say)
     expected = '<Gather><Say>%s</Say></Gather>' % text
     assert gather.xml == expected
     gather.removeElementAtIndex(0)
     expected = '<Gather></Gather>'
     assert gather.xml == expected
Example #7
0
    def test_init_remove_element_at_index(self):
        text = 'Hello from Zang!'
        say = Say(text)
        response = Response()
        response.addElement(say)

        expected = XML_DECLARATION + \
            '<Response><Say>%s</Say></Response>' % text
        assert response.xml == expected
        response.removeElementAtIndex(0)
        expected = XML_DECLARATION + '<Response></Response>'
        assert response.xml == expected
Example #8
0
 def test_init_add_element(self):
     number = '(555)555-5555'
     dial = Dial(number=number)
     text = 'Hello from Zang!'
     say = Say(text)
     response = Response()
     response.addElement(dial)
     response.addElement(say)
     expected = XML_DECLARATION + \
         '<Response><Dial>%s</Dial><Say>%s</Say></Response>' \
         % (number, text)
     assert response.xml == expected
Example #9
0
 def test_udefinded_method_with_base_node(self):
     self.assertRaises(AttributeError,
                       lambda: Say(self.text).addElement(BaseNode()))
Example #10
0
 def test_udefinded_method_with_primitive_type(self):
     self.assertRaises(AttributeError,
                       lambda: Say(self.text).addElement('bar'))
Example #11
0
 def test_init_with_unsupported_attributes(self):
     self.assertRaises(TypeError, lambda: Say(self.text, foo='bar'))
Example #12
0
 def test_init_with_optional_attributes(self):
     loop = 100
     say = Say(self.text, loop=loop)
     expected = '<Say loop="%s">%s</Say>' % (loop, self.text)
     assert say.xml == expected
Example #13
0
 def test_init_with_required_values(self):
     expected = '<Say>' + self.text + '</Say>'
     assert Say(self.text).xml == expected