Permalink
Browse files

Add tests for redaction of geometries

  • Loading branch information...
1 parent d204cf9 commit 13561a9c3341687123b148ad394ff9fc163ea328 @Gnonthgol Gnonthgol committed Apr 28, 2012
Showing with 50 additions and 0 deletions.
  1. +26 −0 test_relation.rb
  2. +24 −0 test_way.rb
View
@@ -176,6 +176,32 @@ def test_relation_members_added_then_removed
Redact[OSM::Relation, 1, 3, :visible]
], actions)
end
+
+ # member added as the first member by a decliner, that means that the member added in
+ # the third version have to be inserted as first and not as seccond member
+ def test_relation_members_added_by_decliner
+ history = [OSM::Relation[[ [OSM::Way,3] ], :id => 1, :changeset => 1, :version => 1 ], #agreer
+ OSM::Relation[[ [OSM::Way,1] , [OSM::Way,3] ], :id => 1, :changeset => 3, :version => 2 ], #decliner
+ OSM::Relation[[ [OSM::Way,1] , [OSM::Way,2] , [OSM::Way,3] ], :id => 1, :changeset => 2, :version => 3 ]] #agreer
+ bot = ChangeBot.new(@db)
+ actions = bot.action_for(history)
+ assert_equal([Edit[OSM::Relation[[ [OSM::Way,2], [OSM::Way,3] ], :id => 1, :changeset => -1, :version => 3]],
+ Redact[OSM::Relation, 1, 2, :hidden],
+ Redact[OSM::Relation, 1, 3, :visible]
+ ], actions)
+ end
+
+ def test_relation_members_added_then_moved
+ history = [OSM::Relation[[ [OSM::Way,2] , [OSM::Way,3] ], :id => 1, :changeset => 1, :version => 1 ], #agreer
+ OSM::Relation[[ [OSM::Way,1] , [OSM::Way,2] , [OSM::Way,3] ], :id => 1, :changeset => 3, :version => 2 ], #decliner
+ OSM::Relation[[ [OSM::Way,3] , [OSM::Way,1] , [OSM::Way,2] ], :id => 1, :changeset => 2, :version => 3 ]] #agreer
+ bot = ChangeBot.new(@db)
+ actions = bot.action_for(history)
+ assert_equal([Edit[OSM::Relation[[ [OSM::Way,3] , [OSM::Way,2] ], :id => 1, :changeset => -1, :version => 3]],
+ Redact[OSM::Relation, 1, 2, :hidden],
+ Redact[OSM::Relation, 1, 3, :visible]
+ ], actions)
+ end
end
if __FILE__ == $0
View
@@ -188,6 +188,30 @@ def test_way_all_tags_changed
assert_equal([Redact[OSM::Way, 1, 1, :hidden]], actions)
end
+ def test_way_nodes_added_first
+ history = [OSM::Way[[ 3], :id=>1, :changeset=>1, :version=>1], # created by agreer
+ OSM::Way[[1, 3], :id=>1, :changeset=>3, :version=>2], # node added to the front by decliner
+ OSM::Way[[1,2,3], :id=>1, :changeset=>2, :version=>3]] # node addition by agreer
+ bot = ChangeBot.new(@db)
+ actions = bot.action_for(history)
+ assert_equal([Edit[OSM::Way[[2,3], :id=>1, :changeset=>-1, :version=>3]],
+ Redact[OSM::Way, 1, 2, :hidden],
+ Redact[OSM::Way, 1, 3, :visible]
+ ], actions)
+ end
+
+ def test_way_nodes_added_and_reversed
+ history = [OSM::Way[[1,2 ], :id=>1, :changeset=>1, :version=>1], # created by agreer
+ OSM::Way[[1,2,3], :id=>1, :changeset=>3, :version=>2], # node added by decliner
+ OSM::Way[[3,2,1], :id=>1, :changeset=>2, :version=>3]] # way reversed by agreer
+ bot = ChangeBot.new(@db)
+ actions = bot.action_for(history)
+ assert_equal([Edit[OSM::Way[[2,1], :id=>1, :changeset=>-1, :version=>3]],
+ Redact[OSM::Way, 1, 2, :hidden],
+ Redact[OSM::Way, 1, 3, :visible]
+ ], actions)
+ end
+
# ** FIXME: add some more way tests here, and some relation ones too.
end

0 comments on commit 13561a9

Please sign in to comment.