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_parent():
h = '8928308280fffff'
assert h3.h3_to_parent(h, 7) == '872830828ffffff'
assert h3.h3_to_parent(h, 8) == '8828308281fffff'
assert h3.h3_to_parent(h, 9) == h
with pytest.raises(H3ResolutionError):
h3.h3_to_parent(h, 10)
def test_parent():
h = '8928308280fffff'
assert h3.h3_to_parent(h, 7) == '872830828ffffff'
assert h3.h3_to_parent(h, 8) == '8828308281fffff'
assert h3.h3_to_parent(h, 9) == h
with pytest.raises(H3ResolutionError):
h3.h3_to_parent(h, 10)
def test_h3_to_parent():
h = '89283082813ffff'
assert h3.h3_to_parent(h, 8) == '8828308281fffff'
def test_parent():
h = '8928308280fffff'
assert h3.h3_to_parent(h, 7) == '872830828ffffff'
assert h3.h3_to_parent(h, 8) == '8828308281fffff'
assert h3.h3_to_parent(h, 9) == h
with pytest.raises(H3ResolutionError):
h3.h3_to_parent(h, 10)
def test_validation():
h = '8a28308280fffff' # invalid cell
with pytest.raises(H3CellError):
h3.h3_get_base_cell(h)
with pytest.raises(H3CellError):
h3.h3_get_resolution(h)
with pytest.raises(H3CellError):
h3.h3_to_parent(h, 9)
with pytest.raises(H3CellError):
h3.h3_distance(h, h)
with pytest.raises(H3CellError):
h3.k_ring(h, 1)
with pytest.raises(H3CellError):
h3.hex_ring(h, 1)
with pytest.raises(H3CellError):
h3.h3_to_children(h, 11)
with pytest.raises(H3CellError):
h3.compact({h})
def test_parent():
h = '8928308280fffff'
assert h3.h3_to_parent(h, 7) == '872830828ffffff'
assert h3.h3_to_parent(h, 8) == '8828308281fffff'
assert h3.h3_to_parent(h, 9) == h
with pytest.raises(H3ResolutionError):
h3.h3_to_parent(h, 10)