示例#1
0
 def test_can_create_with_no_postal_code(self):
     address = dtos.Address(address_type_id=a_string(),
                            location_id=a_string(),
                            city=a_string(),
                            country=a_string(),
                            address_lines=a_string(),
                            state_province=a_string())
     self.assertIsNone(address.postal_code)
示例#2
0
def parse_address(address, site_id, address_type_id):
    city = parse_city(address)
    if not city:
        return None
    country = parse_country(address)
    if not country:
        return None
    return dtos.Address(location_id=site_id,
                        address_type_id=address_type_id,
                        city=city,
                        country=country,
                        address_lines=parse_address_lines(address),
                        state_province=parse_state_province(address),
                        postal_code=parse_postal_code(address))
示例#3
0
 def test_can_create(self):
     address = dtos.Address(location_id='location_id',
                            address_type_id='address_type_id',
                            city='city',
                            country='country',
                            address_lines='address_lines',
                            state_province='state_province',
                            postal_code='postal_code')
     self.assertEqual(address.location_id, 'location_id')
     self.assertEqual(address.address_type_id, 'address_type_id')
     self.assertEqual(address.city, 'city')
     self.assertEqual(address.country, 'country')
     self.assertEqual(address.address_lines, 'address_lines')
     self.assertEqual(address.state_province, 'state_province')
     self.assertEqual(address.postal_code, 'postal_code')
示例#4
0
def parse_address(address, site_id, address_type_id):
    address_lines = parse_address_lines(address)
    city = parse_city(address)
    country = parse_country(address)
    if not address_lines or not city or not country:
        LOGGER.warning(
            'Unable to create address for location: "%s". '
            'Parsed "%s" for address, "%s" for city, and "%s" for country.',
            site_id, address_lines, city, country)
        return None
    state_province = parse_state_province(address)
    postal_code = parse_postal_code(address)
    return dtos.Address(location_id=site_id,
                        address_lines=address_lines,
                        city=city,
                        state_province=state_province,
                        postal_code=postal_code,
                        country=country,
                        address_type_id=address_type_id)
示例#5
0
 def test_throws_on_missing_country(self):
     with self.assertRaises(
             exceptions.MissingRequiredFieldXmlParseException):
         dtos.Address(location_id=a_string(),
                      address_type_id=a_string(),
                      city=a_string())