Skip to content

Commit

Permalink
[FIX] Custom filter unit test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodlam committed Jun 14, 2023
1 parent 3920379 commit fb02189
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name = "LightOSM"
uuid = "d1922b25-af4e-4ba3-84af-fe9bea896051"
authors = ["Jack Chan <[email protected]>"]
version = "0.2.9"
version = "0.2.10"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Expand Down
59 changes: 38 additions & 21 deletions test/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,53 @@ end
catch
end
end
end

#run test for custom filters
try
wait_for_overpass()
filename = "map.json"
format = :json
custom_filters = """way
@testset "Download with custom filters" begin
filename = "map.json"
format = :json
custom_filters = """
way
["highway"]
["motorcar"!~"no"]
["area"!~"yes"]
["highway"!~"elevator|steps|tertiary|construction|bridleway|proposed|track|pedestrian|secondary|path|living_street|cycleway|primary|footway|platform|abandoned|service|escalator|corridor|raceway"]
["highway"!~"elevator|steps|tertiary|construction|bridleway|proposed|track|pedestrian|secondary|path|living_street|cycleway|primary|footway|platform|abandoned|service|escalator|corridor|raceway"]
["motor_vehicle"!~"no"]["access"!~"private"]
["service"!~"parking|parking_aisle|driveway|private|emergency_access"]
;
>
;
"""

bbox = [-37.816779513558274, 144.9590750877158, -37.81042034950731, 144.967124565619]

test_custom_query = download_osm_network(:custom_filters, download_format=format,
save_to_file_location=filename,
custom_filters = custom_filters, bbox = bbox)
;
>
;
"""
bbox = [-37.816779513558274, 144.9590750877158, -37.81042034950731, 144.967124565619]

try
wait_for_overpass()
test_custom_query = download_osm_network(
:custom_filters,
download_format=format,
save_to_file_location=filename,
custom_filters=custom_filters,
bbox = bbox
)

@test isfile(filename)
g = graph_from_file(filename)
for (_, way) in g.ways
# Make sure Overpass excluded these tags, as they are excluded in the filter
highway_tags_to_check = ["primary", "secondary", "tertiary", "living_street"]
if haskey(way.tags, "highway")
@test way.tags["highway"] highway_tags_to_check
end
end
catch err

@warn "Could not build graph"
rethrow()
# Sometimes gets HTTP.ExceptionRequest.StatusError in tests due to connection to overpass
!isa(err, HTTP.ExceptionRequest.StatusError) && rethrow()
@error "Test failed due to connection issue" exception = (err, catch_backtrace())
end

# Remove file after test
try
rm(filename)
catch
end
end

2 comments on commit fb02189

@jarodlam
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/85536

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.10 -m "<description of version>" fb02189e329e1fa62d37278d99388787c3353718
git push origin v0.2.10

Please sign in to comment.