forked from zerebubuth/openstreetmap-license-change
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_odbl_tag.rb
89 lines (79 loc) · 4.08 KB
/
test_odbl_tag.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require './change_bot'
require './user'
require './changeset'
require './db'
require './actions'
require './util.rb'
require 'minitest/unit'
class TestOdblTag < MiniTest::Unit::TestCase
def setup
@db = DB.new(:changesets => {
1 => Changeset[User[true]],
2 => Changeset[User[true]],
3 => Changeset[User[false]]
})
end
# --------------------------------------------------------------------------
# Tests concerning odbl=clean tag
# --------------------------------------------------------------------------
# odbl=clean overrides previous object history, but old versions still need to be redacted
def test_node_odbl_clean
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "odbl" => "clean"]] # odbl=clean added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
# as above, but with differently-cased odbl=clean tag
def test_node_odbl_clean_case_insensitive
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "ODbL" => "Clean"]] # odbl=clean added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
# Some people like to use "yes" instead of "clean"
def test_node_odbl_clean_case_insensitive_yes
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "oDbL" => "yEs"]] # odbl=clean added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
# Some people like to use "true" instead of "clean"
def test_node_odbl_clean_case_insensitive_true
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "oDbL" => "TrUe"]] # odbl=clean added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
# Some people like to use "1" instead of "clean"
def test_node_odbl_clean_case_insensitive_one
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "oDbL" => "1"]] # odbl=clean added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
# Cater for the typo obdl=clean
def test_node_obdl_clean
history = [OSM::Node[[0,0], :id=>1, :changeset => 1, :version => 1], # created by agreer
OSM::Node[[0,0], :id=>1, :changeset => 3, :version => 2, "foo" => "bar"], # edited by decliner
OSM::Node[[0,0], :id=>1, :changeset => 2, :version => 3, "foo" => "bar", "obdl" => "clean"]] # obdl=clean (typo) added by agreer
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
assert_equal([Redact[OSM::Node, 1, 2, :hidden],
], actions)
end
end