Ejemplo n.º 1
0
 def test_can_create_with_none_value_for_phone_numbers(self):
     phone_numbers = None
     location = dtos.Location(id=a_string(),
                              name=a_string(),
                              organization_id=a_string(),
                              phone_numbers=phone_numbers)
     self.assertEqual(location.services, phone_numbers)
Ejemplo n.º 2
0
 def test_can_create_with_none_value_for_services(self):
     services = None
     location = dtos.Location(id=a_string(),
                              name=a_string(),
                              organization_id=a_string(),
                              services=services)
     self.assertEqual(location.services, services)
Ejemplo n.º 3
0
 def test_throws_on_list_of_wrong_type_for_services(self):
     services = [a_string()]
     with self.assertRaises(exceptions.InvalidTypeXmlParseException):
         dtos.Location(id=a_string(),
                       name=a_string(),
                       organization_id=a_string(),
                       services=services)
Ejemplo n.º 4
0
 def test_throws_on_list_of_wrong_type_for_phone_numbers(self):
     phone_numbers = [a_string()]
     with self.assertRaises(exceptions.InvalidTypeXmlParseException):
         dtos.Location(id=a_string(),
                       name=a_string(),
                       organization_id=a_string(),
                       phone_numbers=phone_numbers)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def test_throws_on_single_service_for_services(self):
     service = dtos.Service(id=a_string(),
                            name=a_string(),
                            organization_id=a_string(),
                            site_id=a_string())
     with self.assertRaises(exceptions.InvalidTypeXmlParseException):
         dtos.Location(id=a_string(),
                       name=a_string(),
                       organization_id=a_string(),
                       services=service)
Ejemplo n.º 7
0
 def test_can_create_with_list_of_service_dtos_for_services(self):
     service = dtos.Service(id=a_string(),
                            name=a_string(),
                            organization_id=a_string(),
                            site_id=a_string())
     services = [service]
     location = dtos.Location(id=a_string(),
                              name=a_string(),
                              organization_id=a_string(),
                              services=services)
     self.assertEqual(location.services, services)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
def parse_site(site, organization_id):
    id = parse_site_id(site)
    name = parse_site_name(site)
    description = parse_site_description(site)
    spatial_location = parse_spatial_location_if_defined(site)
    services = parse_services(site, organization_id, id)
    physical_address = parse_physical_address(site, id)
    postal_address = parse_postal_address(site, id)
    LOGGER.info('Parsed location: %s %s', id, name)
    return dtos.Location(id=id,
                         name=name,
                         organization_id=organization_id,
                         description=description,
                         spatial_location=spatial_location,
                         services=services,
                         physical_address=physical_address,
                         postal_address=postal_address)
Ejemplo n.º 10
0
 def test_throws_on_missing_organization_id(self):
     with self.assertRaises(
             exceptions.MissingRequiredFieldXmlParseException):
         dtos.Location(id='id', name='name')