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_get_h3_unidirectional_edge():
out = h3.get_h3_unidirectional_edge('8928308280fffff', '8928308280bffff')
assert h3.h3_unidirectional_edge_is_valid(out)
with pytest.raises(ValueError):
h3.get_h3_unidirectional_edge('821c07fffffffff', '8928308280fffff')
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_get_h3_unidirectional_edge():
out = h3.get_h3_unidirectional_edge('8928308280fffff', '8928308280bffff')
assert h3.h3_unidirectional_edge_is_valid(out)
with pytest.raises(ValueError):
h3.get_h3_unidirectional_edge('821c07fffffffff', '8928308280fffff')
def test_edges():
h = '8928308280fffff'
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_edge_boundary():
h1 = '8928308280fffff'
h2 = '89283082873ffff'
e = h3.get_h3_unidirectional_edge(h1, h2)
expected = (
(37.77688044840226, -122.41612835779266),
(37.778385004930925, -122.41738797617619)
)
out = h3.get_h3_unidirectional_edge_boundary(e)
assert out[0] == pytest.approx(expected[0])
assert out[1] == pytest.approx(expected[1])
def test_edges():
h = '8928308280fffff'
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)