예제 #1
0
def test_postal_code_negative(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_ca.postal_code, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) or\
           (match.group(0) != utils.unicode_str(input))
예제 #2
0
def test_occupancy_positive(input, expected):
    ''' tests exact string match for a place id '''
    match = utils.match(data_ca.occupancy, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
예제 #3
0
def test_full_address_positive(input, expected):
    ''' tests exact string match for a full address '''
    match = utils.match(data_ca.full_address, utils.unicode_str(input),
                        re.VERBOSE | re.U)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
예제 #4
0
def test_street_number_negative(input, expected):
    ''' tests negative string match for a street number '''
    match = utils.match(data_ca.street_number, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    """we check that:
       - input should not to match our regex
       - our match should be partial if regex matches some part of string
    """
    assert (is_found == expected) or \
           (match.group(0) != utils.unicode_str(input))
예제 #5
0
def test_building(input, expected):
    ''' tests string match for a building '''
    is_found = utils.match(
        data_ca.building,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
예제 #6
0
def test_floor(input, expected):
    ''' tests string match for a floor '''
    is_found = utils.match(
        data_ca.floor,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
예제 #7
0
def test_street_type(input, expected):
    ''' tests string match for a street id '''
    is_found = utils.match(
        data_ca.street_type,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
예제 #8
0
def test_post_direction(input, expected):
    ''' tests string match for a post_direction '''
    is_found = utils.match(
        data_ca.post_direction,
        utils.unicode_str(input), re.VERBOSE)\
        is not None
    assert is_found == expected
예제 #9
0
def test_street_number_positive(input, expected):
    ''' tests positive exact string match for a street number '''
    match = utils.match(data_ca.street_number, input, re.VERBOSE)
    is_found = match is not None
    # check for exact match
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
예제 #10
0
def test_region1(input, expected):
    ''' test exact string match for province '''
    match = utils.match(data_ca.region1, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and \
        match.group(0) == utils.unicode_str(input)
예제 #11
0
def test_po_box_negative(input, expected):
    ''' tests string match for a po box '''
    match = utils.match(data_ca.po_box, utils.unicode_str(input), re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
예제 #12
0
def test_po_box_positive(input, expected):
    ''' tests exact string match for a po box '''
    match = utils.match(data_ca.po_box, utils.unicode_str(input), re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and\
           (match.group(0) == utils.unicode_str(input))
예제 #13
0
def test_occupancy_negative(input, expected):
    ''' tests string match for a place id '''
    match = utils.match(data_ca.occupancy, utils.unicode_str(input),
                        re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)