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
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
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
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))
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))
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
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
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
def test_udefinded_method_with_base_node(self): self.assertRaises(AttributeError, lambda: Say(self.text).addElement(BaseNode()))
def test_udefinded_method_with_primitive_type(self): self.assertRaises(AttributeError, lambda: Say(self.text).addElement('bar'))
def test_init_with_unsupported_attributes(self): self.assertRaises(TypeError, lambda: Say(self.text, foo='bar'))
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
def test_init_with_required_values(self): expected = '<Say>' + self.text + '</Say>' assert Say(self.text).xml == expected