Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
# Neo4j versions lower than 3.4.0 do not support Point. In that case, skip the test.
check_and_skip_neo4j_least_version(340, 'This version does not support spatial data types.')
# The test is repeatable enough to try and standardise it. The same test is repeated with the assertions in
# `basic_type_assertions` and different messages to be able to localise the exception.
#
# Array of points to inflate and messages when things go wrong
values_from_db = [(neo4j.v1.spatial.CartesianPoint((0.0, 0.0)),
'Expected Neomodel 2d cartesian point when inflating 2d cartesian neo4j point'),
(neo4j.v1.spatial.CartesianPoint((0.0, 0.0, 0.0)),
'Expected Neomodel 3d cartesian point when inflating 3d cartesian neo4j point'),
(neo4j.v1.spatial.WGS84Point((0.0, 0.0)),
'Expected Neomodel 2d geographical point when inflating 2d geographical neo4j point'),
(neo4j.v1.spatial.WGS84Point((0.0, 0.0, 0.0)),
'Expected Neomodel 3d geographical point inflating 3d geographical neo4j point')]
# Run the above tests
for a_value in values_from_db:
expected_point = neomodel.contrib.spatial_properties.NeomodelPoint(tuple(a_value[0]),
crs=neomodel.contrib.spatial_properties.SRID_TO_CRS[a_value[0].srid])
inflated_point = neomodel.contrib.spatial_properties.PointProperty(
crs=neomodel.contrib.spatial_properties.SRID_TO_CRS[a_value[0].srid]).inflate(a_value[0])
basic_type_assertions(expected_point, inflated_point, '{}, received {}'.format(a_value[1], inflated_point))