Ejemplo n.º 1
0
 def testEmergency(self):
     wrongTypeCounter = 0
     for regionCode in phonenumberutil.SUPPORTED_REGIONS:
         metadata = PhoneMetadata.metadata_for_region(regionCode, None)
         desc = metadata.emergency
         if desc.example_number is not None:
             exampleNumber = desc.example_number
             if (not fullmatch(re.compile(desc.possible_number_pattern),
                               exampleNumber)
                     or not is_emergency_number(exampleNumber, regionCode)):
                 wrongTypeCounter += 1
                 print >> sys.stderr, "Emergency example number test failed for %s" % regionCode
     self.assertEqual(0, wrongTypeCounter)
    def testCanBeInternationallyDialled(self):
        for regionCode in phonenumberutil.SUPPORTED_REGIONS:
            exampleNumber = None
            metadata = PhoneMetadata.metadata_for_region(regionCode, None)
            desc = None
            if metadata is not None:
                desc = metadata.no_international_dialling
            try:
                if desc.example_number is not None:
                    exampleNumber = phonenumberutil.parse(desc.example_number, regionCode)

            except NumberParseException, e:
                print >> sys.stderr, "Failed parse: %s" % e

            if (exampleNumber is not None and
                phonenumberutil._can_be_internationally_dialled(exampleNumber)):
                self.wrong_type_cases.append(exampleNumber)
                print >> sys.stderr, "Number %s should not be internationally diallable" % exampleNumber
    def testCanBeInternationallyDialled(self):
        for regionCode in phonenumberutil.SUPPORTED_REGIONS:
            exampleNumber = None
            metadata = PhoneMetadata.metadata_for_region(regionCode, None)
            desc = None
            if metadata is not None:
                desc = metadata.no_international_dialling
            try:
                if desc.example_number is not None:
                    exampleNumber = phonenumberutil.parse(desc.example_number, regionCode)

            except NumberParseException:
                _, e, _ = sys.exc_info()
                prnt("Failed parse: %s" % e, file=sys.stderr)

            if (exampleNumber is not None and
                phonenumberutil._can_be_internationally_dialled(exampleNumber)):
                self.wrong_type_cases.append(exampleNumber)
                prnt("Number %s should not be internationally diallable" % exampleNumber, file=sys.stderr)
        self.assertEqual(0, len(self.wrong_type_cases))
    def testCanBeInternationallyDialled(self):
        for regionCode in phonenumberutil.SUPPORTED_REGIONS:
            exampleNumber = None
            metadata = PhoneMetadata.metadata_for_region(regionCode, None)
            desc = None
            if metadata is not None:
                desc = metadata.no_international_dialling
            try:
                if desc is not None and desc.example_number is not None:
                    exampleNumber = phonenumberutil.parse(desc.example_number, regionCode)

            except NumberParseException:
                _, e, _ = sys.exc_info()
                prnt("Failed parse: %s" % e, file=sys.stderr)

            if (exampleNumber is not None and
                phonenumberutil.can_be_internationally_dialled(exampleNumber)):
                self.wrong_type_cases.append(exampleNumber)
                prnt("Number %s should not be internationally diallable" % exampleNumber, file=sys.stderr)
        self.assertEqual(0, len(self.wrong_type_cases))
 def testMetadataPrint(self):
     for callingCode in PhoneMetadata._region_available.keys():
         metadata = PhoneMetadata.metadata_for_region("GB")
         str(metadata)
Ejemplo n.º 6
0
 def testMetadataPrint(self):
     # Python version extra test
     # Convert all metadata to strings to check the printing code doesn't blow up.
     for region_code in PhoneMetadata._region_available.keys():
         metadata = PhoneMetadata.metadata_for_region(region_code)
         str(metadata)
 def testMetadataPrint(self):
     for callingCode in PhoneMetadata._region_available.keys():
         metadata = PhoneMetadata.metadata_for_region("GB")
         str(metadata)