Пример #1
0
 def test_parses_phone_phone_number(self):
     site_id = a_string()
     phone_type = a_string()
     phone_number = a_phone_number()
     xml = self.build_phone_xml(phone_number, phone_type)
     root = etree.fromstring(xml)
     phone_number_list = parser.parse_site_phone_number_list(root, site_id)
     self.assertEqual(phone_number_list[0].phone_number, phone_number)
Пример #2
0
 def test_parses_phone_into_expected_dto_object(self):
     site_id = a_string()
     phone_type = a_string()
     phone_number = a_phone_number()
     xml = self.build_phone_xml(phone_number, phone_type)
     root = etree.fromstring(xml)
     phone_number_list = parser.parse_site_phone_number_list(root, site_id)
     self.assertIsInstance(phone_number_list[0], dtos.PhoneAtLocation)
Пример #3
0
 def test_parses_phone_type_and_converts_to_id(self):
     site_id = a_string()
     phone_type = 'A phone TYPE'
     phone_number = a_phone_number()
     xml = self.build_phone_xml(phone_number, phone_type)
     root = etree.fromstring(xml)
     phone_number_list = parser.parse_site_phone_number_list(root, site_id)
     self.assertEqual(phone_number_list[0].phone_number_type_id,
                      'a_phone_type')
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
0
 def test_throws_on_missing_phone_number_type_id(self):
     with self.assertRaises(
             exceptions.MissingRequiredFieldXmlParseException):
         dtos.PhoneAtLocation(phone_number=a_phone_number(),
                              location_id=a_string())
Пример #8
0
 def test_a_phone_number_is_numeric(self):
     return self.assertTrue(a_phone_number().isnumeric())
Пример #9
0
 def test_a_phone_number_by_default_has_length_10(self):
     return self.assertEqual(len(a_phone_number()), 10)
Пример #10
0
 def __init__(self, location):
     self.location = location
     self.phone_number_type = PhoneNumberType(id=a_string())
     self.phone_number = a_phone_number()