Permalink
Browse files

Merge pull request #7 from harry-wood/master

minor basic comments & docs
  • Loading branch information...
2 parents 2f6ac80 + aa83f2a commit 8c6d7645313e9cbdc8deecb32680fd3dd1bbd834 @zerebubuth zerebubuth committed Mar 27, 2012
Showing with 34 additions and 12 deletions.
  1. +14 −5 README.md
  2. +20 −7 test_node.rb
View
@@ -20,8 +20,17 @@ be individually run to concentrate on some aspects of the suite.
This code is intended to be read as a test-driven development. It's
very hard to read most code when it implements a complex algorithm,
especially when it is expected to be read by anyone not fluent in the
-language of choice (i.e: Ruby).
-
-In order to improve the understandability of the code, this project is
-intended to be test-driven, with well-commented tests to define the
-functionality.
+language of choice (i.e: Ruby). In order to improve the
+understandability of the code, this project is intended to be
+test-driven, with well-commented tests to define the functionality.
+Hopefully these tests *are* quite easy to read, without being a ruby
+expert.
+
+Tests can be found in the various files prefixed 'test_'. For example
+tests_node.rb contains a set of tests to run just involving nodes,
+and this is a good place to start. You'll find tests which describe
+nodes being created, moved, and having tags changed by various users
+ (license change agreers and disagreers in various combinations).
+A test then the gives the expected resulting actions which a bot
+should be deciding upon, to put the node in a clean state, and to
+redact versions from the editing history.
View
@@ -7,10 +7,16 @@
require 'test/unit'
class TestNode < Test::Unit::TestCase
+
+ # Setup prior to each of the node tests below
+ # Changesets 1 & 2 are by agreers. Changeset 3 is by a disagreer.
+ # References to these numbers appear in the tests below, while the
+ # the actual data of the changesets is initialised differently for
+ # each test.
def setup
- @db = DB.new(1 => Changeset[User[true]],
- 2 => Changeset[User[true]],
- 3 => Changeset[User[false]])
+ @db = DB.new(1 => Changeset[User[true]], #agreer
+ 2 => Changeset[User[true]], #agreer
+ 3 => Changeset[User[false]]) #disagreer
end
# if a node has been edited only by people who have agreed then
@@ -20,16 +26,20 @@ def test_simple_node_clean
OSM::Node[[0,0], :changeset => 2]]
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
- assert_equal([], actions)
+ assert_equal([], actions) #the bot should take no actions (empty actions array)
end
# if a node has been created by a person who hasn't agreed then
# it should be deleted and the one version redacted.
def test_simple_node_unclean
- history = [OSM::Node[[0,0], :id => 1, :changeset => 3, :version => 1]]
+ history = [OSM::Node[[0,0], :id => 1, :changeset => 3, :version => 1]] #node created in changeset 3 (by a disagreer)
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
- assert_equal([Delete[OSM::Node, 1], Redact[OSM::Node, 1, 1, :hidden]], actions)
+
+ # bot should return an array of actions. These are structs defined in actions.rb
+ assert_equal([Delete[OSM::Node, 1], #node should be deleted
+ Redact[OSM::Node, 1, 1, :hidden] #version 1 of node id 1 should be redacted
+ ], actions)
end
# if a node has been created by a person who hasn't agreed and
@@ -40,7 +50,10 @@ def test_simple_node_unclean_multiple_edit
OSM::Node[[0,0], :id => 1, :changeset => 3, :version => 2]]
bot = ChangeBot.new(@db)
actions = bot.action_for(history)
- assert_equal([Delete[OSM::Node, 1], Redact[OSM::Node, 1, 1, :hidden], Redact[OSM::Node, 1, 2, :hidden]], actions)
+ assert_equal([Delete[OSM::Node, 1],
+ Redact[OSM::Node, 1, 1, :hidden],
+ Redact[OSM::Node, 1, 2, :hidden]
+ ], actions)
end
# by the "version zero" rule, then a node which has been created

0 comments on commit 8c6d764

Please sign in to comment.