Ejemplo n.º 1
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))
Ejemplo n.º 2
0
def execute_matching_test(input, expected, pattern):
    match = utils.match(pattern, input, re.VERBOSE)
    is_found = match is not None
    if expected:
        assert is_found == expected and match.group(0) == input
    else:
        assert (is_found == expected) or (match.group(0) != input)
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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))
Ejemplo n.º 7
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))
Ejemplo n.º 8
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))
Ejemplo n.º 9
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
Ejemplo n.º 10
0
def test_street_name_negative(input, expected):
    ''' tests positive string match for a street name '''
    match = utils.match(data_us.street_number, 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) != input)
Ejemplo n.º 11
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))
Ejemplo n.º 12
0
def execute_matching_test(input, expected, pattern):
    match = utils.match(pattern, input, re.VERBOSE)
    is_found = match is not None
    if expected:
        assert is_found == expected and match.group(0) == input
    else:
        """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) != input)
Ejemplo n.º 13
0
def test_zero_to_nine(input, expected):
    ''' test string match for zero_to_nine '''
    is_found = utils.match(data_us.zero_to_nine, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 14
0
def test_full_address_negative(input, expected):
    ''' tests string match for a full address '''
    match = utils.match(data_us.full_address, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected
Ejemplo n.º 15
0
def test_hundred(input, expected):
    ''' tests string match for a hundred '''
    is_found = utils.match(data_ca.hundred, input, re.VERBOSE) is not None
    assert is_found == expected
Ejemplo n.º 16
0
def test_country(input, expected):
    ''' test exact string match for country '''
    match = utils.match(data_ca.country, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
Ejemplo n.º 17
0
def test_floor(input, expected):
    ''' tests string match for a floor '''
    is_found = utils.match(data_us.floor, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
def test_hundred(input, expected):
    ''' tests string match for a hundred '''
    is_found = utils.match(data_us.hundred, input, re.VERBOSE) is not None
    assert is_found == expected
Ejemplo n.º 21
0
def test_country(input, expected):
    ''' test exact string match for country '''
    match = utils.match(data_us.country, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
Ejemplo n.º 22
0
def test_region1(input, expected):
    ''' test exact string match for province '''
    match = utils.match(data_us.region1, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
Ejemplo n.º 23
0
def test_ten_to_ninety(input, expected):
    ''' test string match for ten_to_ninety '''
    is_found = utils.match(data_us.ten_to_ninety, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 24
0
def test_postal_code_negative(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_us.postal_code, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) or (match.group(0) != input)
Ejemplo n.º 25
0
def test_postal_code_positive(input, expected):
    ''' test exact string match for postal code '''
    match = utils.match(data_us.postal_code, input, re.VERBOSE)
    is_found = match is not None
    assert is_found == expected and match.group(0) == input
Ejemplo n.º 26
0
def test_occupancy_positive(input, expected):
    ''' tests exact string match for a place id '''
    match = utils.match(data_us.occupancy, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
Ejemplo n.º 27
0
def test_zero_to_nine(input, expected):
    ''' test string match for zero_to_nine '''
    is_found = utils.match(data_ca.zero_to_nine, input, re.VERBOSE) is not None
    assert is_found == expected
Ejemplo n.º 28
0
def test_thousand(input, expected):
    ''' tests string match for a thousand '''
    is_found = utils.match(data_us.thousand, input, re.VERBOSE) is not None
    assert is_found == expected
Ejemplo n.º 29
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))
Ejemplo n.º 30
0
def test_street_type(input, expected):
    ''' tests string match for a street id '''
    is_found = utils.match(data_us.street_type, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 31
0
def test_building(input, expected):
    ''' tests string match for a building '''
    is_found = utils.match(data_us.building, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 32
0
def test_po_box_negative(input, expected):
    ''' tests string match for a po box '''
    match = utils.match(data_us.po_box, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
Ejemplo n.º 33
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)
Ejemplo n.º 34
0
def test_po_box_positive(input, expected):
    ''' tests exact string match for a po box '''
    match = utils.match(data_us.po_box, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
Ejemplo n.º 35
0
def test_ten_to_ninety(input, expected):
    ''' test string match for ten_to_ninety '''
    is_found = utils.match(data_ca.ten_to_ninety, input, re.VERBOSE)\
        is not None
    assert is_found == expected
Ejemplo n.º 36
0
def test_occupancy_negative(input, expected):
    ''' tests string match for a place id '''
    match = utils.match(data_us.occupancy, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected)
Ejemplo n.º 37
0
def test_thousand(input, expected):
    ''' tests string match for a thousand '''
    is_found = utils.match(data_ca.thousand, input, re.VERBOSE) is not None
    assert is_found == expected
Ejemplo n.º 38
0
def test_full_address_positive(input, expected):
    ''' tests exact string match for a full address '''
    match = utils.match(data_us.full_address, input, re.VERBOSE)
    is_found = match is not None
    assert (is_found == expected) and (match.group(0) == input)
Ejemplo n.º 39
0
def test_street_number_positive(input, expected):
    ''' tests positive exact string match for a street number '''
    match = utils.match(data_us.street_number, input, re.VERBOSE)
    is_found = match is not None
    # check for exact match
    assert (is_found == expected) and (match.group(0) == input)
Ejemplo n.º 40
0
def test_post_direction(input, expected):
    ''' tests string match for a post_direction '''
    is_found = utils.match(data_us.post_direction, input, re.VERBOSE)\
        is not None
    assert is_found == expected