# Path: shiji/i18n/postal_code_validator.py
# class PostalCodeValidator (object):
# class PostalCodeDataFileDNEError(Exception):
# class InvalidISO2DCountryCodeError(Exception):
# class UnsupportedCountryError(Exception):
#     def __init__(self, postal_data_path=None):
#     def supported_countries(self):
#     def load_country(self, iso_code, pattern):
#     def valid_postal_code(self, iso_code, postal_code):
#     def valid_postal_code_global(self, postal_code):
#     def __init__(self, path):
#     def __init__(self):
#     def __init__(self, iso_code):


import os
from twisted.trial import unittest
from shiji.i18n import postal_code_validator
#
#
# $Id$
# ###################################################################
# (C)2015 DigiTar Inc.
# Licensed under the MIT License.
# ###################################################################

class PostalCodeValidatorTests(unittest.TestCase):
    "Postal code validator tests."
    
    def setUp(self):
        script_path = os.path.dirname(os.path.realpath(__file__))
        self.fn_postal_data = "%s/sample_cldr_data/postalCodeData.xml" % script_path
        
        self.sample_postal_data = {"GB" : """GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}}"""
                                  }
        
        self.good_postal_codes = {"GB" : "DN55 1PT",
                                  "DE" : "39130",
                                  "JP" : "196-0025"}
        
        
        self.bad_postal_codes = {"GB" : "DN55 XPT",
                                 "DE" : "39x30",
                                 "JP" : "196-00x5"}
    
    
    def test_load_country_ok(self):
        """Verify loading valid country postal code data."""

# Path: shiji/i18n/postal_code_validator.py
# class PostalCodeValidator (object):
# class PostalCodeDataFileDNEError(Exception):
# class InvalidISO2DCountryCodeError(Exception):
# class UnsupportedCountryError(Exception):
#     def __init__(self, postal_data_path=None):
#     def supported_countries(self):
#     def load_country(self, iso_code, pattern):
#     def valid_postal_code(self, iso_code, postal_code):
#     def valid_postal_code_global(self, postal_code):
#     def __init__(self, path):
#     def __init__(self):
#     def __init__(self, iso_code):


# Path: shiji/tests/test_i18n.py
import os
from twisted.trial import unittest
from shiji.i18n import postal_code_validator

#
#
# $Id$
# ###################################################################
# (C)2015 DigiTar Inc.
# Licensed under the MIT License.
# ###################################################################

class PostalCodeValidatorTests(unittest.TestCase):
    "Postal code validator tests."
    
    def setUp(self):
        script_path = os.path.dirname(os.path.realpath(__file__))
        self.fn_postal_data = "%s/sample_cldr_data/postalCodeData.xml" % script_path
        
        self.sample_postal_data = {"GB" : """GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}}"""
                                  }
        
        self.good_postal_codes = {"GB" : "DN55 1PT",
                                  "DE" : "39130",
                                  "JP" : "196-0025"}
        
        
        self.bad_postal_codes = {"GB" : "DN55 XPT",
                                 "DE" : "39x30",
                                 "JP" : "196-00x5"}
    
    
    def test_load_country_ok(self):
        """Verify loading valid country postal code data."""

        validator = postal_code_validator.PostalCodeValidator()