def test_empty(self): """ An empty element produces a ``None`` value keyed against its tag name. """ self.assertEqual( {'root': None}, element_to_dict(L.root()))
def test_empty_attributes(self): """ An element containing only attributes, and no content, has its attributes, prefixed with an ``@`` keyed against its tag name. """ self.assertEqual( {'root': {'@attr': 'value'}}, element_to_dict(L.root(attr='value')))
def test_empty_attributes(self): """ An element containing only attributes, and no content, has its attributes, prefixed with an ``@`` keyed against its tag name. """ self.assertEqual({'root': { '@attr': 'value' }}, element_to_dict(L.root(attr='value')))
def test_text(self): """ An element containing only text content, has its text keyed against its tag name. """ self.assertEqual( {'root': 'hello'}, element_to_dict(L.root('hello')))
def test_text_attributes(self): """ An element containing attributes and text content, has its attributes, prefixed with an ``@`` keyed against its tag name and its text keyed against ``#text``. """ self.assertEqual( {'root': {'#text': 'hello', '@attr': 'value'}}, element_to_dict(L.root('hello', attr='value')))
def test_children_multiple(self): """ Multiple child elements with the same tag name are coalesced into a ``list``. """ self.assertEqual( {'root': {'child': [{'@attr': 'value'}, 'hello']}}, element_to_dict( L.root(L.child(attr='value'), L.child('hello'))))
def test_process_empty(self): """ `SmsNotificationService.process` raises `SoapFault` if there are no actionable child elements in the request body. """ service = SmsNotificationService(None, None) exc = self.assertRaises(SoapFault, service.process, None, L.root()) self.assertEqual(('soapenv:Client', 'No actionable items'), (exc.code, str(exc)))
def test_text_attributes(self): """ An element containing attributes and text content, has its attributes, prefixed with an ``@`` keyed against its tag name and its text keyed against ``#text``. """ self.assertEqual({'root': { '#text': 'hello', '@attr': 'value' }}, element_to_dict(L.root('hello', attr='value')))
def test_children_multiple(self): """ Multiple child elements with the same tag name are coalesced into a ``list``. """ self.assertEqual({'root': { 'child': [{ '@attr': 'value' }, 'hello'] }}, element_to_dict(L.root(L.child(attr='value'), L.child('hello'))))
def test_children_text(self): """ Child elements are recursively nested. An element containing only text content, has its text keyed against its tag name. """ self.assertEqual({'root': { 'child': 'hello' }}, element_to_dict(L.root(L.child('hello'))))
def test_children_text(self): """ Child elements are recursively nested. An element containing only text content, has its text keyed against its tag name. """ self.assertEqual( {'root': {'child': 'hello'}}, element_to_dict( L.root(L.child('hello'))))
def test_process_unknown(self): """ `SmsNotificationService.process` invokes `SmsNotificationService.process_unknown`, for handling otherwise unknown requests, which raises `SoapFault`. """ service = SmsNotificationService(None, None) exc = self.assertRaises(SoapFault, service.process, None, L.root(L.WhatIsThis)) self.assertEqual(('soapenv:Server', 'No handler for WhatIsThis'), (exc.code, str(exc)))
def test_children_attributes(self): """ Child elements are recursively nested. An element containing only attributes, and no content, has its attributes, prefixed with an ``@`` keyed against its tag name. """ self.assertEqual( {'root': {'child': {'@attr': 'value'}}}, element_to_dict( L.root(L.child(attr='value'))))
def test_process_empty(self): """ `SmsNotificationService.process` raises `SoapFault` if there are no actionable child elements in the request body. """ service = SmsNotificationService(None, None) exc = self.assertRaises(SoapFault, service.process, None, L.root()) self.assertEqual( ('soapenv:Client', 'No actionable items'), (exc.code, str(exc)))
def test_children_attributes(self): """ Child elements are recursively nested. An element containing only attributes, and no content, has its attributes, prefixed with an ``@`` keyed against its tag name. """ self.assertEqual({'root': { 'child': { '@attr': 'value' } }}, element_to_dict(L.root(L.child(attr='value'))))
def test_process_unknown(self): """ `SmsNotificationService.process` invokes `SmsNotificationService.process_unknown`, for handling otherwise unknown requests, which raises `SoapFault`. """ service = SmsNotificationService(None, None) exc = self.assertRaises(SoapFault, service.process, None, L.root(L.WhatIsThis)) self.assertEqual( ('soapenv:Server', 'No handler for WhatIsThis'), (exc.code, str(exc)))
def test_text(self): """ An element containing only text content, has its text keyed against its tag name. """ self.assertEqual({'root': 'hello'}, element_to_dict(L.root('hello')))
def test_empty(self): """ An empty element produces a ``None`` value keyed against its tag name. """ self.assertEqual({'root': None}, element_to_dict(L.root()))