implement BDD osm2pgsql tests with pytest-bdd

This commit is contained in:
Sarah Hoffmann
2025-03-31 09:39:01 +02:00
parent 0f725b1880
commit fb440f29a2
18 changed files with 2409 additions and 17 deletions

View File

@@ -0,0 +1,135 @@
Feature: Updates of address interpolation objects
Test that changes to address interpolation objects are correctly
propagated.
Background:
Given the grid
| 1 | 2 |
Scenario: Adding a new interpolation
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential,name=Tao Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
When updating osm data
"""
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | place | houses |
When indexing
Then placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W33 | highway | residential |
Then location_property_osmline contains exactly
| osm_id | startnumber |
| 99 | 5 |
Scenario: Delete an existing interpolation
When loading osm data
"""
n1 Taddr:housenumber=2
n2 Taddr:housenumber=7
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | place | houses |
When updating osm data
"""
w99 v2 dD
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
When indexing
Then placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
Then location_property_osmline contains exactly
| osm_id |
Scenario: Changing an object to an interpolation
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential Nn1,n2
w99 Thighway=residential Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | highway | residential |
When updating osm data
"""
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | place | houses |
When indexing
Then placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W33 | highway | residential |
And location_property_osmline contains exactly
| osm_id | startnumber |
| 99 | 5 |
Scenario: Changing an interpolation to something else
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w99 Taddr:interpolation=odd Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | place | houses |
When updating osm data
"""
w99 Thighway=residential Nn1,n2
"""
Then place contains
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | highway | residential |
When indexing
Then placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W99 | highway | residential |
And location_property_osmline contains exactly
| osm_id |

View File

@@ -0,0 +1,167 @@
Feature: Update of postcode only objects
Tests that changes to objects containing only a postcode are
propagated correctly.
Scenario: Adding a postcode-only node
When loading osm data
"""
n1
"""
Then place contains exactly
| object |
When updating osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | class | type |
| N34 | place | postcode |
When indexing
Then placex contains exactly
| object |
Scenario: Deleting a postcode-only node
When loading osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | class | type |
| N34 | place | postcode |
When updating osm data
"""
n34 v2 dD
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario Outline: Converting a regular object into a postcode-only node
When loading osm data
"""
n34 T<class>=<type>
"""
Then place contains exactly
| object | class | type |
| N34 | <class> | <type> |
When updating osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | class | type |
| N34 | place | postcode |
When indexing
Then placex contains exactly
| object |
Examples:
| class | type |
| amenity | restaurant |
| place | hamlet |
Scenario Outline: Converting a postcode-only node into a regular object
When loading osm data
"""
n34 Tpostcode=4456
"""
Then place contains exactly
| object | class | type |
| N34 | place | postcode |
When updating osm data
"""
n34 T<class>=<type>
"""
Then place contains exactly
| object | class | type |
| N34 | <class> | <type> |
When indexing
Then placex contains exactly
| object | class | type |
| N34 | <class> | <type> |
Examples:
| class | type |
| amenity | restaurant |
| place | hamlet |
Scenario: Converting na interpolation into a postcode-only node
Given the grid
| 1 | 2 |
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w34 Taddr:interpolation=odd Nn1,n2
"""
Then place contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W34 | place | houses |
When updating osm data
"""
w34 Tpostcode=4456 Nn1,n2
"""
Then place contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W34 | place | postcode |
When indexing
Then location_property_osmline contains exactly
| osm_id |
And placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
Scenario: Converting a postcode-only node into an interpolation
Given the grid
| 1 | 2 |
When loading osm data
"""
n1 Taddr:housenumber=3
n2 Taddr:housenumber=17
w33 Thighway=residential Nn1,n2
w34 Tpostcode=4456 Nn1,n2
"""
Then place contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W33 | highway | residential |
| W34 | place | postcode |
When updating osm data
"""
w34 Taddr:interpolation=odd Nn1,n2
"""
Then place contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W33 | highway | residential |
| W34 | place | houses |
When indexing
Then location_property_osmline contains exactly
| osm_id | startnumber | endnumber |
| 34 | 5 | 15 |
And placex contains exactly
| object | class | type |
| N1 | place | house |
| N2 | place | house |
| W33 | highway | residential |

View File

@@ -0,0 +1,140 @@
Feature: Update of relations by osm2pgsql
Testing relation update by osm2pgsql.
Scenario: Remove all members of a relation
When loading osm data
"""
n1 Tamenity=prison,name=foo
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45' Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XZ' |
When updating osm data
"""
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mn1@
"""
Then place has no entry for R1
Scenario: Change type of a relation
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XZ Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XZ' |
When updating osm data
"""
r1 Ttype=multipolygon,amenity=prison,name=XZ Mw2@
"""
Then place has no entry for R1:tourism
And place contains
| object | class | type | name!dict |
| R1 | amenity | prison | 'name' : 'XZ' |
Scenario: Change name of a relation
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=AB Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'AB' |
When updating osm data
"""
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XY' |
Scenario: Change type of a relation into something unknown
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttype=multipolygon,amenities=prison,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Type tag is removed
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttourism=hotel,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Type tag is renamed to something unknown
When loading osm data
"""
n200 x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
w2 Tref=45 Nn200,n201,n202,n203,n200
r1 Ttype=multipolygon,tourism=hotel,name=XY Mw2@
"""
Then place contains
| object | class | type | name!dict |
| R1 | tourism | hotel | 'name' : 'XY' |
When updating osm data
"""
r1 Ttype=multipolygonn,tourism=hotel,name=XY Mw2@
"""
Then place has no entry for R1
Scenario: Country boundary names are left untouched when country_code unknown
When loading osm data
"""
n200 Tamenity=prison x0 y0
n201 x0 y0.0001
n202 x0.0001 y0.0001
n203 x0.0001 y0
"""
And updating osm data
"""
w1 Nn200,n201,n202,n203,n200
r1 Ttype=boundary,boundary=administrative,name=Foo,country_code=XX,admin_level=2 Mw1@
"""
Then place contains
| object | address+country | name!dict |
| R1 | XX | 'name' : 'Foo' |

View File

@@ -0,0 +1,48 @@
Feature: Update of simple objects by osm2pgsql
Testing basic update functions of osm2pgsql.
Scenario: Adding a new object
When loading osm data
"""
n1 Tplace=town,name=Middletown
"""
Then place contains exactly
| object | class | type | name+name |
| N1 | place | town | Middletown |
When updating osm data
"""
n2 Tamenity=hotel,name=Posthotel
"""
Then place contains exactly
| object | class | type | name+name |
| N1 | place | town | Middletown |
| N2 | amenity | hotel | Posthotel |
And placex contains exactly
| object | class | type | name+name | indexed_status |
| N1 | place | town | Middletown | 0 |
| N2 | amenity | hotel | Posthotel | 1 |
Scenario: Deleting an existing object
When loading osm data
"""
n1 Tplace=town,name=Middletown
n2 Tamenity=hotel,name=Posthotel
"""
Then place contains exactly
| object | class | type | name+name |
| N1 | place | town | Middletown |
| N2 | amenity | hotel | Posthotel |
When updating osm data
"""
n2 dD
"""
Then place contains exactly
| object | class | type | name+name |
| N1 | place | town | Middletown |
And placex contains exactly
| object | class | type | name+name | indexed_status |
| N1 | place | town | Middletown | 0 |
| N2 | amenity | hotel | Posthotel | 100 |

View File

@@ -0,0 +1,512 @@
Feature: Tag evaluation
Tests if tags are correctly updated in the place table
Background:
Given the grid
| 1 | 2 | 3 |
| 10 | 11 | |
| 45 | 46 | |
Scenario: Main tag deleted
When loading osm data
"""
n1 Tamenity=restaurant
n2 Thighway=bus_stop,railway=stop,name=X
n3 Tamenity=prison
"""
Then place contains exactly
| object | class | type |
| N1 | amenity | restaurant |
| N2 | highway | bus_stop |
| N2 | railway | stop |
| N3 | amenity | prison |
When updating osm data
"""
n1 Tnot_a=restaurant
n2 Thighway=bus_stop,name=X
"""
Then place contains exactly
| object | class | type |
| N2 | highway | bus_stop |
| N3 | amenity | prison |
And placex contains
| object | class | indexed_status |
| N3 | amenity | 0 |
When indexing
Then placex contains exactly
| object | class | type | name!dict |
| N2 | highway | bus_stop | 'name': 'X' |
| N3 | amenity | prison | - |
Scenario: Main tag added
When loading osm data
"""
n1 Tatity=restaurant
n2 Thighway=bus_stop,name=X
"""
Then place contains exactly
| object | class | type |
| N2 | highway | bus_stop |
When updating osm data
"""
n1 Tamenity=restaurant
n2 Thighway=bus_stop,railway=stop,name=X
"""
Then place contains exactly
| object | class | type |
| N1 | amenity | restaurant |
| N2 | highway | bus_stop |
| N2 | railway | stop |
When indexing
Then placex contains exactly
| object | class | type | name!dict |
| N1 | amenity | restaurant | - |
| N2 | highway | bus_stop | 'name': 'X' |
| N2 | railway | stop | 'name': 'X' |
Scenario: Main tag modified
When loading osm data
"""
n10 Thighway=footway,name=X
n11 Tamenity=atm
"""
Then place contains exactly
| object | class | type |
| N10 | highway | footway |
| N11 | amenity | atm |
When updating osm data
"""
n10 Thighway=path,name=X
n11 Thighway=primary
"""
Then place contains exactly
| object | class | type |
| N10 | highway | path |
| N11 | highway | primary |
When indexing
Then placex contains exactly
| object | class | type | name!dict |
| N10 | highway | path | 'name': 'X' |
| N11 | highway | primary | - |
Scenario: Main tags with name, name added
When loading osm data
"""
n45 Tlanduse=cemetry
n46 Tbuilding=yes
"""
Then place contains exactly
| object | class | type |
When updating osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type |
| N45 | landuse | cemetry |
| N46 | building| yes |
When indexing
Then placex contains exactly
| object | class | type | name!dict | address!dict |
| N45 | landuse | cemetry | 'name': 'TODO' | - |
| N46 | building| yes | - | 'housenumber': '1' |
Scenario: Main tags with name, name removed
When loading osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type |
| N45 | landuse | cemetry |
| N46 | building| yes |
When updating osm data
"""
n45 Tlanduse=cemetry
n46 Tbuilding=yes
"""
Then place contains exactly
| object | class | type |
When indexing
Then placex contains exactly
| object |
Scenario: Main tags with name, name modified
When loading osm data
"""
n45 Tlanduse=cemetry,name=TODO
n46 Tbuilding=yes,addr:housenumber=1
"""
Then place contains exactly
| object | class | type | name!dict | address!dict |
| N45 | landuse | cemetry | 'name' : 'TODO' | - |
| N46 | building| yes | - | 'housenumber': '1'|
When updating osm data
"""
n45 Tlanduse=cemetry,name=DONE
n46 Tbuilding=yes,addr:housenumber=10
"""
Then place contains exactly
| object | class | type | name!dict | address!dict |
| N45 | landuse | cemetry | 'name' : 'DONE' | - |
| N46 | building| yes | - | 'housenumber': '10'|
When indexing
Then placex contains exactly
| object | class | type | name!dict | address!dict |
| N45 | landuse | cemetry | 'name' : 'DONE' | - |
| N46 | building| yes | - | 'housenumber': '10'|
Scenario: Main tag added to address only node
When loading osm data
"""
n1 Taddr:housenumber=345
"""
Then place contains exactly
| object | class | type | address!dict |
| N1 | place | house | 'housenumber': '345'|
When updating osm data
"""
n1 Taddr:housenumber=345,building=yes
"""
Then place contains exactly
| object | class | type | address!dict |
| N1 | building | yes | 'housenumber': '345'|
When indexing
Then placex contains exactly
| object | class | type | address!dict |
| N1 | building | yes | 'housenumber': '345'|
Scenario: Main tag removed from address only node
When loading osm data
"""
n1 Taddr:housenumber=345,building=yes
"""
Then place contains exactly
| object | class | type | address!dict |
| N1 | building | yes | 'housenumber': '345'|
When updating osm data
"""
n1 Taddr:housenumber=345
"""
Then place contains exactly
| object | class | type | address!dict |
| N1 | place | house | 'housenumber': '345'|
When indexing
Then placex contains exactly
| object | class | type | address!dict |
| N1 | place | house | 'housenumber': '345'|
Scenario: Main tags with name key, adding key name
When loading osm data
"""
n2 Tbridge=yes
"""
Then place contains exactly
| object | class | type |
When updating osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name': 'high' |
When indexing
Then placex contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name': 'high' |
Scenario: Main tags with name key, deleting key name
When loading osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name': 'high' |
When updating osm data
"""
n2 Tbridge=yes
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario: Main tags with name key, changing key name
When loading osm data
"""
n2 Tbridge=yes,bridge:name=high
"""
Then place contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name': 'high' |
When updating osm data
"""
n2 Tbridge=yes,bridge:name:en=high
"""
Then place contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name:en': 'high' |
When indexing
Then placex contains exactly
| object | class | type | name!dict |
| N2 | bridge | yes | 'name:en': 'high' |
Scenario: Downgrading a highway to one that is dropped without name
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=residential Nn100,n101
"""
Then place contains exactly
| object | class |
| W1 | highway |
When updating osm data
"""
w1 Thighway=service Nn100,n101
"""
Then place contains exactly
| object |
When indexing
Then placex contains exactly
| object |
Scenario: Upgrading a highway to one that is not dropped without name
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=service Nn100,n101
"""
Then place contains exactly
| object |
When updating osm data
"""
w1 Thighway=unclassified Nn100,n101
"""
Then place contains exactly
| object | class |
| W1 | highway |
When indexing
Then placex contains exactly
| object | class |
| W1 | highway |
Scenario: Downgrading a highway when a second tag is present
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=residential,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | class | type |
| W1 | highway | residential |
| W1 | tourism | hotel |
When updating osm data
"""
w1 Thighway=service,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | class | type |
| W1 | tourism | hotel |
When indexing
Then placex contains exactly
| object | class | type |
| W1 | tourism | hotel |
Scenario: Upgrading a highway when a second tag is present
When loading osm data
"""
n100 x0 y0
n101 x0.0001 y0.0001
w1 Thighway=service,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | class | type |
| W1 | tourism | hotel |
When updating osm data
"""
w1 Thighway=residential,tourism=hotel Nn100,n101
"""
Then place contains exactly
| object | class | type |
| W1 | highway | residential |
| W1 | tourism | hotel |
When indexing
Then placex contains exactly
| object | class | type |
| W1 | highway | residential |
| W1 | tourism | hotel |
Scenario: Replay on administrative boundary
When loading osm data
"""
n10 x34.0 y-4.23
n11 x34.1 y-4.23
n12 x34.2 y-4.13
w10 Tboundary=administrative,waterway=river,name=Border,admin_level=2 Nn12,n11,n10
"""
Then place contains exactly
| object | class | type | admin_level | name!dict |
| W10 | waterway | river | 2 | 'name': 'Border' |
| W10 | boundary | administrative | 2 | 'name': 'Border' |
When updating osm data
"""
w10 Tboundary=administrative,waterway=river,name=Border,admin_level=2 Nn12,n11,n10
"""
Then place contains exactly
| object | class | type | admin_level | name!dict |
| W10 | waterway | river | 2 | 'name': 'Border' |
| W10 | boundary | administrative | 2 | 'name': 'Border' |
When indexing
Then placex contains exactly
| object | class | type | admin_level | name!dict |
| W10 | waterway | river | 2 | 'name': 'Border' |
Scenario: Change admin_level on administrative boundary
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=2 Mw10@
"""
Then place contains exactly
| object | class | admin_level |
| R10 | boundary | 2 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | class | type | admin_level |
| R10 | boundary | administrative | 4 |
When indexing
Then placex contains exactly
| object | class | type | admin_level |
| R10 | boundary | administrative | 4 |
Scenario: Change boundary to administrative
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=informal,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | class | type | admin_level |
| R10 | boundary | informal | 4 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | class | type | admin_level |
| R10 | boundary | administrative | 4 |
When indexing
Then placex contains exactly
| object | class | type | admin_level |
| R10 | boundary | administrative | 4 |
Scenario: Change boundary away from administrative
Given the grid
| 10 | 11 |
| 13 | 12 |
When loading osm data
"""
n10
n11
n12
n13
w10 Nn10,n11,n12,n13,n10
r10 Ttype=multipolygon,boundary=administrative,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | class | type | admin_level |
| R10 | boundary | administrative | 4 |
When updating osm data
"""
r10 Ttype=multipolygon,boundary=informal,name=Border,admin_level=4 Mw10@
"""
Then place contains exactly
| object | class | type | admin_level |
| R10 | boundary | informal | 4 |
When indexing
Then placex contains exactly
| object | class | type | admin_level |
| R10 | boundary | informal | 4 |
Scenario: Main tag and geometry is changed
When loading osm data
"""
n1 x40 y40
n2 x40.0001 y40
n3 x40.0001 y40.0001
n4 x40 y40.0001
w5 Tbuilding=house,name=Foo Nn1,n2,n3,n4,n1
"""
Then place contains exactly
| object | class | type |
| W5 | building | house |
When updating osm data
"""
n1 x39.999 y40
w5 Tbuilding=terrace,name=Bar Nn1,n2,n3,n4,n1
"""
Then place contains exactly
| object | class | type |
| W5 | building | terrace |