Example #1
0
def parse_site_phone(phone, site_id):
    location_id = site_id
    phone_number_type_id = convert_phone_type_to_type_id(
        phone.find('Type').text)
    phone_number = phone.find('PhoneNumber').text
    return dtos.PhoneAtLocation(location_id=location_id,
                                phone_number_type_id=phone_number_type_id,
                                phone_number=phone_number)
Example #2
0
 def test_throws_on_single_phone_at_location_for_phone_numbers(self):
     phone_at_location = dtos.PhoneAtLocation(
         location_id=a_string(),
         phone_number_type_id=a_string(),
         phone_number=a_phone_number())
     with self.assertRaises(exceptions.InvalidTypeXmlParseException):
         dtos.Location(id=a_string(),
                       name=a_string(),
                       organization_id=a_string(),
                       phone_numbers=phone_at_location)
Example #3
0
 def test_can_create_with_list_of_phone_at_location_dtos_for_phone_numbers(
         self):
     phone_at_location = dtos.PhoneAtLocation(
         location_id=a_string(),
         phone_number_type_id=a_string(),
         phone_number=a_phone_number())
     phones_at_location = [phone_at_location]
     location = dtos.Location(id=a_string(),
                              name=a_string(),
                              organization_id=a_string(),
                              phone_numbers=phones_at_location)
     self.assertEqual(location.phone_numbers, phones_at_location)
Example #4
0
 def test_can_create(self):
     location_id = a_string()
     phone_number_type_id = a_string()
     phone_number = a_phone_number()
     phone_at_location = dtos.PhoneAtLocation(
         location_id=location_id,
         phone_number_type_id=phone_number_type_id,
         phone_number=phone_number)
     self.assertEqual(phone_at_location.location_id, location_id)
     self.assertEqual(phone_at_location.phone_number_type_id,
                      phone_number_type_id)
     self.assertEqual(phone_at_location.phone_number, phone_number)
Example #5
0
 def test_throws_on_missing_phone_number(self):
     with self.assertRaises(
             exceptions.MissingRequiredFieldXmlParseException):
         dtos.PhoneAtLocation(phone_number_type_id=a_string(),
                              location_id=a_string())