Exemple #1
0
def test_h3_is_valid():
    assert h3.h3_is_valid('85283473fffffff')
    assert h3.h3_is_valid('850dab63fffffff')
    assert not h3.h3_is_valid('lolwut')

    # H3 0.x Addresses are not considered valid
    assert not h3.h3_is_valid('5004295803a88')

    for res in range(16):
        assert h3.h3_is_valid(h3.geo_to_h3(37, -122, res))
def test8():
    assert h3.h3_is_valid('89283082803ffff')
    assert not h3.h3_is_valid('abc')

    # looks like it might be valid, but it isn't!
    h_bad = '8a28308280fffff'
    assert not h3.h3_is_valid(h_bad)

    # other methods should validate and raise exception if bad input
    with pytest.raises(H3CellError):
        h3.h3_get_resolution(h_bad)
Exemple #3
0
def test_bad_units():
    h = '89754e64993ffff'
    e = '139754e64993ffff'

    assert h3.h3_is_valid(h)
    assert h3.h3_unidirectional_edge_is_valid(e)

    with pytest.raises(H3ValueError):
        h3.cell_area(h, unit='foot-pounds')

    with pytest.raises(H3ValueError):
        h3.exact_edge_length(h, unit='foot-pounds')

    with pytest.raises(H3ValueError):
        h3.point_dist((0, 0), (0, 0), unit='foot-pounds')
def test_edge():
    h1 = '8928308280fffff'
    h2 = '89283082873ffff'

    assert not h3.h3_indexes_are_neighbors(h1, h1)
    assert h3.h3_indexes_are_neighbors(h1, h2)

    e = h3.get_h3_unidirectional_edge(h1, h2)

    assert e == '12928308280fffff'
    assert h3.h3_unidirectional_edge_is_valid(e)
    assert not h3.h3_is_valid(e)

    assert h3.get_origin_h3_index_from_unidirectional_edge(e) == h1
    assert h3.get_destination_h3_index_from_unidirectional_edge(e) == h2

    assert h3.get_h3_indexes_from_unidirectional_edge(e) == (h1, h2)
def test_hex2int_fail():
    h_invalid = {}

    assert not h3.h3_is_valid(h_invalid)