From d3452eafda705c022809cb1abd2ed04c3413eff9 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Wed, 30 Sep 2015 14:30:55 +0200 Subject: [PATCH] improve tests and actually fix #65 and #66 previous fix only worked by accident because way and relation ids were the same --- diff/deleter.go | 6 ++++-- test/complete_db.osc | 14 +++++++------- test/complete_db.osm | 24 ++++++++++++------------ test/complete_db_test.py | 10 +++++----- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/diff/deleter.go b/diff/deleter.go index 75d039d..c872f68 100644 --- a/diff/deleter.go +++ b/diff/deleter.go @@ -116,8 +116,10 @@ func (d *Deleter) deleteRelation(id int64, deleteRefs bool, deleteMembers bool) if _, ok := d.deletedWays[member.Id]; ok { continue } - if err := d.deleteRelation(member.Id, false, false); err != nil { - return err + for _, r := range d.diffCache.Ways.Get(member.Id) { + if err := d.deleteRelation(r, false, false); err != nil { + return err + } } if err := d.deleteWay(member.Id, false); err != nil { return err diff --git a/test/complete_db.osc b/test/complete_db.osc index a5c45f7..5f411d2 100644 --- a/test/complete_db.osc +++ b/test/complete_db.osc @@ -190,9 +190,9 @@ - - - + + + @@ -200,8 +200,8 @@ - - + + @@ -210,8 +210,8 @@ - - + + diff --git a/test/complete_db.osm b/test/complete_db.osm index 6073721..4839da7 100644 --- a/test/complete_db.osm +++ b/test/complete_db.osm @@ -1055,9 +1055,9 @@ - - - + + + @@ -1065,8 +1065,8 @@ - - + + @@ -1075,9 +1075,9 @@ relation (201101) with shared way (checks #65) --> - - - + + + @@ -1085,13 +1085,13 @@ - - + + - - + + diff --git a/test/complete_db_test.py b/test/complete_db_test.py index 3a675c9..a4daa44 100644 --- a/test/complete_db_test.py +++ b/test/complete_db_test.py @@ -319,9 +319,9 @@ def test_no_duplicates(): """ highways = t.query_duplicates(t.db_conf, 'osm_roads') # one duplicate for test_node_way_inserted_twice is expected - assert highways == [[18001, 2]] + assert highways == [[18001, 2]], highways landusages = t.query_duplicates(t.db_conf, 'osm_landusages') - assert not landusages + assert not landusages, landusages def test_updated_landusage(): """Multipolygon relation was modified""" @@ -480,9 +480,9 @@ def test_no_duplicate_insert(): Relation is not inserted again if a nother relation with the same way was modified Checks #65 """ - assert t.query_row(t.db_conf, 'osm_landusages', -201101)['type'] == 'park' - assert t.query_row(t.db_conf, 'osm_landusages', -201102)['type'] == 'forest' - assert t.query_row(t.db_conf, 'osm_roads', 201101)['type'] == 'residential' + assert t.query_row(t.db_conf, 'osm_landusages', -201191)['type'] == 'park' + assert t.query_row(t.db_conf, 'osm_landusages', -201192)['type'] == 'forest' + assert t.query_row(t.db_conf, 'osm_roads', 201151)['type'] == 'residential' ####################################################################### def test_deploy_and_revert_deploy():