Example #1
0
 def test_remove_element_at_out_of_range_index(self):
     text = 'Hello from Avaya CPaaS!'
     number = Number(text)
     dial = Dial()
     dial.addElement(number)
     index = len(dial._content)
     self.assertRaises(IndexError, lambda: dial.removeElementAtIndex(index))
Example #2
0
 def test_init_add_element(self):
     text = '(555)555-5555'
     number = Number(text)
     dial = Dial()
     dial.addElement(number)
     expected = '<Dial><Number>%s</Number></Dial>' % text
     assert dial.xml == expected
Example #3
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 #4
0
 def test_init_remove_element_at_index(self):
     text = 'Hello from Avaya CPaaS!'
     number = Number(text)
     dial = Dial()
     dial.addElement(number)
     expected = '<Dial><Number>%s</Number></Dial>' % text
     assert dial.xml == expected
     dial.removeElementAtIndex(0)
     expected = '<Dial></Dial>'
     assert dial.xml == expected
Example #5
0
 def test_init_with_required_values(self):
     expected = '<Dial></Dial>'
     assert Dial().xml == expected
Example #6
0
 def test_udefinded_method_with_base_node(self):
     self.assertRaises(AttributeError, lambda: Dial().url)
Example #7
0
 def test_udefinded_method_with_primitive_type(self):
     self.assertRaises(TypeError, lambda: Dial().addElement(0.5))
Example #8
0
 def test_with_update_attributes(self):
     dial = Dial()
     timeLimit = 0
     dial.timeLimit = 0
     expected = '<Dial timeLimit="%s"></Dial>' % (timeLimit)
     assert dial.xml == expected
Example #9
0
 def test_init_with_unsupported_attributes(self):
     self.assertRaises(TypeError, lambda: Dial(foo='bar'))
Example #10
0
 def test_init_with_optional_attributes(self):
     method = HttpMethod.GET
     dial = Dial(method=method)
     expected = '<Dial method="%s"></Dial>' % (method.value)
     assert dial.xml == expected
Example #11
0
 def test_init_with_arguments(self):
     text = '(555)555-5555'
     dial = Dial(number=text)
     expected = '<Dial>%s</Dial>' % text
     assert dial.xml == expected