コード例 #1
0
 def test_fails_silently_on_empty_address_line(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line1 />
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertIsNone(address_lines)
コード例 #2
0
 def test_removes_doubly_escaped_strong_markup_from_optional_field(self):
     xml_address = '''
     <Site>
         <MailingAddress>
             <Line1>&amp;lt;strong&amp;gt;Line1</Line1>
         </MailingAddress>
     </Site>
     '''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(address_lines, 'Line1')
コード例 #3
0
 def test_address_line_parser_returns_none_when_line_1_is_empty(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line1 />
                 <Line2>Line2</Line2>
                 <Line3>Line3</Line3>
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(address_lines, None)
コード例 #4
0
 def test_address_line_parser_sorts_address_lines(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line3>Line3</Line3>
                 <Line1>Line1</Line1>
                 <Line2>Line2</Line2>
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(address_lines, 'Line1\nLine2\nLine3')
コード例 #5
0
 def test_ignores_invalid_lines(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line0>Line0</Line0>
                 <Line1>Line1</Line1>
                 <Line2 />
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(address_lines, 'Line1')
コード例 #6
0
 def test_address_line_parser_only_parses_lines_one_to_four(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line1>Line1</Line1>
                 <Line2>Line2</Line2>
                 <Line3>Line3</Line3>
                 <Line4>Line4</Line4>
                 <Line5>Line5</Line5>
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(address_lines, 'Line1\nLine2\nLine3\nLine4')
コード例 #7
0
 def test_parses_lines_1_to_9(self):
     xml_address = '''
         <Site>
             <MailingAddress>
                 <Line1>Line1</Line1>
                 <Line2>Line2</Line2>
                 <Line3>Line3</Line3>
                 <Line4>Line4</Line4>
                 <Line5>Line5</Line5>
                 <Line6>Line6</Line6>
                 <Line7>Line7</Line7>
                 <Line8>Line8</Line8>
                 <Line9>Line9</Line9>
             </MailingAddress>
         </Site>'''
     root = etree.fromstring(xml_address)
     address_lines = parser.parse_address_lines(root.find('MailingAddress'))
     self.assertEqual(
         address_lines,
         'Line1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\nLine8\nLine9')