add BDD tests for importing into the new place_entrance table

This commit is contained in:
Sarah Hoffmann
2025-10-24 10:52:25 +02:00
parent 4c91a0bc8d
commit 2dda9079f0
4 changed files with 232 additions and 2 deletions

View File

@@ -953,7 +953,7 @@ function module.set_entrance_filter(data)
ENTRANCE_FUNCTION = data and data.func
if data.main_tags ~= nil and next(data.main_tags) ~= nil then
if data ~= nil and data.main_tags ~= nil and next(data.main_tags) ~= nil then
if data.extra_include ~= nil and next(data.extra_include) == nil then
-- shortcut: no extra tags requested
ENTRANCE_FUNCTION = function(o)

View File

@@ -18,7 +18,7 @@ Feature: Querying fo postcode variants
| 10 | | | | 11 |
And the places
| osm | class | type | name | addr+postcode | geometry |
| W1 | highway | path | De Weide | 3993 DX | 10,11 |
| W1 | highway | path | De Weide | <postcode> | 10,11 |
When importing
When geocoding "3993 DX"
Then result 0 contains

View File

@@ -0,0 +1,124 @@
Feature: Import of entrance objects by osm2pgsql
Testing of correct setup of the entrance table
Scenario: Import simple entrance
When loading osm data
"""
n1 Tshop=sweets,entrance=yes,access=public x4.5 y-4
n2 Trouting:entrance=main x66.1 y0.1
n3 Tentrance=main,routing:entrance=foot x1 y2
n4 Thighway=bus_stop
"""
Then place contains exactly
| object | class | type |
| N1 | shop | sweets |
| N4 | highway | bus_stop |
And place_entrance contains exactly
| osm_id | type | extratags!dict | geometry!wkt |
| 1 | yes | 'shop': 'sweets', 'access': 'public' | 4.5 -4 |
| 2 | main | - | 66.1 0.1 |
| 3 | main | - | 1 2 |
Scenario: Addresses and entrance information can exist on the same node
When loading osm data
"""
n1 Taddr:housenumber=10,addr:street=North,entrance=main
"""
Then place contains exactly
| object | class | type | address+housenumber |
| N1 | place | house | 10 |
And place_entrance contains exactly
| osm_id | type |
| 1 | main |
Scenario Outline: Entrance import can be disabled
Given the lua style file
"""
local flex = require('import-full')
flex.set_entrance_filter<param>
"""
When loading osm data
"""
n1 Tentrance=yes,access=public
n2 Trouting:entrance=main
"""
Then place contains exactly
| object |
And place_entrance contains exactly
| osm_id |
Examples:
| param |
| () |
| (nil) |
| {} |
| {include={'access'}} |
| {main_tags={}} |
Scenario: Entrance import can have custom main tags
Given the lua style file
"""
local flex = require('import-full')
flex.set_entrance_filter{main_tags = {'door'}}
"""
When loading osm data
"""
n1 Tentrance=yes,access=public
n2 Tdoor=foot,entrance=yes
"""
Then place contains exactly
| object |
And place_entrance contains exactly
| osm_id | type | extratags!dict |
| 2 | foot | 'entrance': 'yes' |
Scenario: Entrance import can have custom extra tags included
Given the lua style file
"""
local flex = require('import-full')
flex.set_entrance_filter{main_tags = {'entrance'},
extra_include = {'access'}}
"""
When loading osm data
"""
n1 Tentrance=yes,access=public,shop=newspaper
n2 Tentrance=yes,shop=sweets
"""
Then place_entrance contains exactly
| osm_id | type | extratags!dict |
| 1 | yes | 'access': 'public' |
| 2 | yes | - |
Scenario: Entrance import can have custom extra tags excluded
Given the lua style file
"""
local flex = require('import-full')
flex.set_entrance_filter{main_tags = {'entrance', 'door'},
extra_exclude = {'shop'}}
"""
When loading osm data
"""
n1 Tentrance=yes,access=public,shop=newspaper
n2 Tentrance=yes,door=yes,shop=sweets
"""
Then place_entrance contains exactly
| osm_id | type | extratags!dict |
| 1 | yes | 'access': 'public' |
| 2 | yes | - |
Scenario: Entrance import can have a custom function
Given the lua style file
"""
local flex = require('import-full')
flex.set_entrance_filter{func = function(object)
return {entrance='always', extratags = {ref = '1'}}
end}
"""
When loading osm data
"""
n1 Tentrance=yes,access=public,shop=newspaper
n2 Tshop=sweets
"""
Then place_entrance contains exactly
| osm_id | type | extratags!dict |
| 1 | always | 'ref': '1' |
| 2 | always | 'ref': '1' |

View File

@@ -0,0 +1,106 @@
Feature: Update of entrance objects by osm2pgsql
Testing of correct update of the entrance table
Scenario: A new entrance is added
When loading osm data
"""
n1 Tshop=shoes
"""
Then place_entrance contains exactly
| osm_id |
When updating osm data
"""
n2 Tentrance=yes
"""
Then place_entrance contains exactly
| osm_id | type |
| 2 | yes |
Scenario: An existing entrance is deleted
When loading osm data
"""
n1 Tentrance=yes
"""
Then place_entrance contains exactly
| osm_id | type |
| 1 | yes |
When updating osm data
"""
n1 dD
"""
Then place_entrance contains exactly
| osm_id |
Scenario: An existing node becomes an entrance
When loading osm data
"""
n1 Tshop=sweets
"""
Then place_entrance contains exactly
| osm_id | type |
And place contains exactly
| object | class |
| N1 | shop |
When updating osm data
"""
n1 Tshop=sweets,entrance=yes
"""
Then place_entrance contains exactly
| osm_id | type |
| 1 | yes |
And place contains exactly
| object | class |
| N1 | shop |
Scenario: An existing entrance tag is removed
When loading osm data
"""
n1 Tshop=sweets,entrance=yes
"""
Then place_entrance contains exactly
| osm_id | type |
| 1 | yes |
And place contains exactly
| object | class |
| N1 | shop |
When updating osm data
"""
n1 Tshop=sweets
"""
Then place_entrance contains exactly
| osm_id | type |
And place contains exactly
| object | class |
| N1 | shop |
Scenario: Extratags are added to an entrance
When loading osm data
"""
n1 Tentrance=yes
"""
Then place_entrance contains exactly
| osm_id | type | extratags |
| 1 | yes | - |
When updating osm data
"""
n1 Tentrance=yes,access=yes
"""
Then place_entrance contains exactly
| osm_id | type | extratags!dict |
| 1 | yes | 'access': 'yes' |
Scenario: Extratags are deleted from an entrance
When loading osm data
"""
n1 Tentrance=yes,access=yes
"""
Then place_entrance contains exactly
| osm_id | type | extratags!dict |
| 1 | yes | 'access': 'yes' |
When updating osm data
"""
n1 Tentrance=yes
"""
Then place_entrance contains exactly
| osm_id | type | extratags |
| 1 | yes | - |