Beispiel #1
0
 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()))
Beispiel #2
0
 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')))
Beispiel #3
0
 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')))
Beispiel #4
0
 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')))
Beispiel #5
0
 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')))
Beispiel #6
0
 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'))))
Beispiel #7
0
 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)))
Beispiel #8
0
 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')))
Beispiel #9
0
 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'))))
Beispiel #10
0
    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'))))
Beispiel #11
0
    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'))))
Beispiel #12
0
 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)))
Beispiel #13
0
    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'))))
Beispiel #14
0
 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)))
Beispiel #15
0
    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'))))
Beispiel #16
0
 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)))
Beispiel #17
0
 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')))
Beispiel #18
0
 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()))