예제 #1
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))
예제 #2
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
예제 #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
예제 #4
0
 def test_init_with_required_values(self):
     expected = XML_DECLARATION + '<Response></Response>'
     assert Response().xml == expected
예제 #5
0
 def test_udefinded_method_with_base_node(self):
     self.assertRaises(AttributeError, lambda: Response().url)
예제 #6
0
 def test_udefinded_method_with_primitive_type(self):
     self.assertRaises(TypeError, lambda: Response().addElement('bar'))
예제 #7
0
 def test_init_with_unsupported_attributes(self):
     self.assertRaises(TypeError, lambda: Response(foo='bar'))