forked from zerebubuth/openstreetmap-license-change
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_exceptions.rb
executable file
·71 lines (62 loc) · 2.34 KB
/
test_exceptions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env ruby
require './change_bot'
require './user'
require './changeset'
require './db'
require './actions'
require './util.rb'
require 'minitest/unit'
class TestExceptions < MiniTest::Unit::TestCase
def setup
@db = DB.new(:changesets => {
1 => Changeset[User[true]],
2 => Changeset[User[true]],
3 => Changeset[User[false]]
})
@db.exclude(OSM::Node, [1, 2, 4])
end
# --------------------------------------------------------------------------
# Tests concerned with special exceptions to the general rule, for which
# we have special cases.
# --------------------------------------------------------------------------
#
# the UMP import in Poland appear to be receiving a lot of very special
# attention, and one thing that's needed here is a special exclusion
# list of "manually uncleaned" items.
#
def test_ump_excluded_node
# this history would ordinarily indicate a clean node, but we have set
# up the exclusion list with a set of IDs which should pass some nodes
# and not others.
{ 1 => true,
2 => true,
3 => false,
4 => true,
5 => false
}.each do |node_id, excluded|
# simple history, with all-clean, all-agreed editors and even an
# odbl=clean tag. all of these are overridden by the UMP exclusion
# list.
history = [OSM::Node[[0,0], :id => node_id, :changeset => 1, :version => 1, "foo" => "bar"],
OSM::Node[[1,0], :id => node_id, :changeset => 1, :version => 2, "foo" => "bar"],
OSM::Node[[1,1], :id => node_id, :changeset => 1, :version => 3, "foo" => "bar", "odbl" => "clean"]]
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
if excluded
# if excluded, we should delete and redact the full history, regardless
# of the clean-ness of the item under the normal rules.
assert_equal([Delete[OSM::Node, node_id],
Redact[OSM::Node, node_id, 1, :hidden],
Redact[OSM::Node, node_id, 2, :hidden],
Redact[OSM::Node, node_id, 3, :hidden]
], actions)
else
# if not excluded, this is a clean node
assert_equal([], actions)
end
end
end
end
if __FILE__ == $0
MiniTest::Unit.new.run(ARGV)
end