def test_missing_country_throws_exception(self): xml_address = ''' <Site> <MailingAddress> <Line1>Line1</Line1> <City>City</City> </MailingAddress> </Site>''' root = etree.fromstring(xml_address) address_type_id = 'postal_address' with self.assertRaisesRegex(MissingRequiredFieldXmlParseException, 'Missing required field: "Country"'): parser.parse_address(root.find('MailingAddress'), a_string(), address_type_id)
def test_fails_silently_on_missing_country(self): xml_address = ''' <Site> <MailingAddress> <Line1>Line1</Line1> <City>City</City> </MailingAddress> </Site>''' root = etree.fromstring(xml_address) address_type_id = 'postal_address' site_id = a_string() self.assertIsNone( parser.parse_address(root.find('MailingAddress'), site_id, address_type_id))
def test_parses_address_with_only_city_and_country(self): xml_address = ''' <Site> <MailingAddress> <City>City</City> <Country>Country</Country> </MailingAddress> </Site>''' root = etree.fromstring(xml_address) address_type_id = 'postal_address' site_id = a_string() address = parser.parse_address(root.find('MailingAddress'), site_id, address_type_id) self.assertIsInstance(address, dtos.Address)
def test_parses_postal_address(self): xml_address = ''' <Site> <MailingAddress> <Line1>Line1</Line1> <City>City</City> <Country>Country</Country> </MailingAddress> </Site>''' root = etree.fromstring(xml_address) address_type_id = 'postal_address' address = parser.parse_address(root.find('MailingAddress'), a_string(), address_type_id) self.assertIsInstance(address, dtos.Address) self.assertEqual(address.address_type_id, address_type_id)