node unit tests with inside limits now.

This commit is contained in:
Shaun McDonald 2008-07-08 15:38:31 +00:00
parent 700da2b347
commit dce4f18a3e
2 changed files with 77 additions and 25 deletions

View file

@ -42,36 +42,64 @@ node_used_by_relationship:
node_too_far_north: node_too_far_north:
id: 6 id: 6
latitude: <%= 91*SCALE %> latitude: <%= 90.01*SCALE %>
longitude: <%= 6*SCALE %> longitude: <%= 6*SCALE %>
user_id: 1 user_id: 1
timestamp: 2007-01-01 00:00:00 timestamp: 2007-01-01 00:00:00
node_north_limit:
id: 11
latitude: <%= 90*SCALE %>
longitude: <%= 11*SCALE %>
user_id: 1
timestamp: 2008-07-08 14:50:00
node_too_far_south: node_too_far_south:
id: 7 id: 7
latitude: <%= -91*SCALE %> latitude: <%= -90.01*SCALE %>
longitude: <%= 7*SCALE %> longitude: <%= 7*SCALE %>
user_id: 1 user_id: 1
timestamp: 2007-01-01 00:00:00 timestamp: 2007-01-01 00:00:00
node_south_limit:
id: 12
latitude: <%= -90*SCALE %>
longitude: <%= 12*SCALE %>
user_id: 1
timestamp: 2008-07-08 15:02:18
node_too_far_west: node_too_far_west:
id: 8 id: 8
latitude: <%= 8*SCALE %> latitude: <%= 8*SCALE %>
longitude: <%= -181*SCALE %> longitude: <%= -180.01*SCALE %>
user_id: 1 user_id: 1
timestamp: 2007-01-01 00:00:00 timestamp: 2007-01-01 00:00:00
node_west_limit:
id: 13
latitude: <%= 13*SCALE %>
longitude: <%= -180*SCALE %>
user_id: 1
timestamp: 2008-07-08 15:17:37
node_too_far_east: node_too_far_east:
id: 9 id: 9
latitude: <%= 9*SCALE %> latitude: <%= 9*SCALE %>
longitude: <%= 181*SCALE %> longitude: <%= 180.01*SCALE %>
user_id: 1 user_id: 1
timestamp: 2007-01-01 00:00:00 timestamp: 2007-01-01 00:00:00
node_east_limit:
id: 14
latitude: <%= 14*SCALE %>
longitude: <%= 180*SCALE %>
user_id: 1
timestamp: 2008-07-08 15:46:16
node_totally_wrong: node_totally_wrong:
id: 10 id: 10
latitude: <%= 1000*SCALE %> latitude: <%= 200*SCALE %>
longitude: <%= 1000*SCALE %> longitude: <%= 200*SCALE %>
user_id: 1 user_id: 1
timestamp: 2007-01-01 00:00:00 timestamp: 2007-01-01 00:00:00

View file

@ -8,40 +8,64 @@ class NodeTest < Test::Unit::TestCase
set_fixture_class :currenr_node_tags => :NodeTag set_fixture_class :currenr_node_tags => :NodeTag
def test_node_too_far_north def test_node_too_far_north
node = current_nodes(:node_too_far_north) invalid_node_test(:node_too_far_north)
assert_equal node.lat, current_nodes(:node_too_far_north).latitude/SCALE end
assert_equal node.lon, current_nodes(:node_too_far_north).longitude/SCALE
assert_equal false, node.valid? def test_node_north_limit
valid_node_test(:node_north_limit)
end end
def test_node_too_far_south def test_node_too_far_south
node = current_nodes(:node_too_far_south) invalid_node_test(:node_too_far_south)
assert_equal node.lat, current_nodes(:node_too_far_south).latitude/SCALE end
assert_equal node.lon, current_nodes(:node_too_far_south).longitude/SCALE
assert_equal false, node.valid? def test_node_south_limit
valid_node_test(:node_south_limit)
end end
def test_node_too_far_west def test_node_too_far_west
node = current_nodes(:node_too_far_west) invalid_node_test(:node_too_far_west)
assert_equal node.lat, current_nodes(:node_too_far_west).latitude/SCALE end
assert_equal node.lon, current_nodes(:node_too_far_west).longitude/SCALE
assert_equal false, node.valid? def test_node_west_limit
valid_node_test(:node_west_limit)
end end
def test_node_too_far_east def test_node_too_far_east
node = current_nodes(:node_too_far_east) invalid_node_test(:node_too_far_east)
assert_equal node.lat, current_nodes(:node_too_far_east).latitude/SCALE end
assert_equal node.lon, current_nodes(:node_too_far_east).longitude/SCALE
assert_equal false, node.valid? def test_node_east_limit
valid_node_test(:node_east_limit)
end end
def test_totally_wrong def test_totally_wrong
node = current_nodes(:node_totally_wrong) invalid_node_test(:node_totally_wrong)
#assert_equal node.lat, current_nodes(:node_totally_wrong).latitude/SCALE end
#assert_equal node.lon, current_nodes(:node_totally_wrong).longitude/SCALE
# This helper method will check to make sure that a node is within the world, and
# has the the same lat, lon and timestamp than what was put into the db by
# the fixture
def valid_node_test(nod)
node = current_nodes(nod)
assert_equal node.lat, current_nodes(nod).latitude.to_f/SCALE
assert_equal node.lon, current_nodes(nod).longitude.to_f/SCALE
assert_equal node.timestamp, current_nodes(nod).timestamp
assert_valid node
end
# This helpermethod will check to make sure that a node is outwith the world,
# and has the same lat, lon and timesamp than what was put into the db by the
# fixture
def invalid_node_test(nod)
node = current_nodes(nod)
assert_equal node.lat, current_nodes(nod).latitude.to_f/SCALE
assert_equal node.lon, current_nodes(nod).longitude.to_f/SCALE
assert_equal node.timestamp, current_nodes(nod).timestamp
assert_equal false, node.valid? assert_equal false, node.valid?
end end
# Check that you can create a node and store it
def test_create def test_create
node_template = Node.new(:latitude => 12.3456, node_template = Node.new(:latitude => 12.3456,
:longitude => 65.4321, :longitude => 65.4321,