Exemple #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()))
Exemple #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')))
Exemple #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')))
Exemple #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')))
Exemple #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')))
Exemple #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'))))
Exemple #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)))
Exemple #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')))
Exemple #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'))))
Exemple #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'))))
Exemple #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'))))
Exemple #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)))
Exemple #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'))))
Exemple #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)))
Exemple #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'))))
Exemple #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)))
Exemple #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')))
Exemple #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()))