Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
with pytest.raises(H3ValueError):
h3.get_h3_unidirectional_edge(h, h)
h2 = h3.hex_ring(h, 2).pop()
with pytest.raises(H3ValueError):
h3.get_h3_unidirectional_edge(h, h2)
e_bad = '14928308280ffff1'
assert not h3.h3_unidirectional_edge_is_valid(e_bad)
with pytest.raises(H3EdgeError):
h3.get_origin_h3_index_from_unidirectional_edge(e_bad)
with pytest.raises(H3EdgeError):
h3.get_destination_h3_index_from_unidirectional_edge(e_bad)
with pytest.raises(H3EdgeError):
h3.get_h3_indexes_from_unidirectional_edge(e_bad)
def test_edges_from_cell():
h = '8928308280fffff'
edges = h3.get_h3_unidirectional_edges_from_hexagon(h)
destinations = {
h3.get_destination_h3_index_from_unidirectional_edge(e)
for e in edges
}
neighbors = h3.hex_ring(h, 1)
assert neighbors == destinations
def test_get_destination_h3_index_from_unidirectional_edge():
h = '11928308280fffff'
out = h3.get_destination_h3_index_from_unidirectional_edge(h)
assert out == '8928308283bffff'