Tests for [17838]

Why is our testing fixtures such a mess? It took me half an hour to find a useable node. And I'm still not sure if it's ok, since I want to get to bed. kthxbye
This commit is contained in:
Thomas Wood 2009-09-29 03:58:33 +00:00
parent ec26e06706
commit 76b6d7d876
7 changed files with 40 additions and 6 deletions

View file

@ -17,3 +17,13 @@ t4:
id: 4 id: 4
node_id: 15 node_id: 15
sequence_id: 1 sequence_id: 1
w5_n1:
id: 5
node_id: 4
sequence_id: 1
w5_n2:
id: 5
node_id: 4
sequence_id: 2

View file

@ -25,3 +25,10 @@ way_with_versions:
timestamp: 2008-01-01 00:04:00 timestamp: 2008-01-01 00:04:00
visible: true visible: true
version: 4 version: 4
way_with_duplicate_nodes:
id: 5
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: true
version: 1

View file

@ -63,3 +63,15 @@ w4_v4_n1:
node_id: 15 node_id: 15
sequence_id: 1 sequence_id: 1
version: 4 version: 4
w5_n1:
id: 5
node_id: 4
sequence_id: 1
version: 1
w5_n2:
id: 5
node_id: 4
sequence_id: 2
version: 1

View file

@ -47,3 +47,9 @@ way_with_versions_v4:
visible: true visible: true
version: 4 version: 4
way_with_duplicate_nodes:
id: 5
changeset_id: 2
timestamp: 2007-01-01 00:00:00
visible: true
version: 1

View file

@ -41,11 +41,10 @@ class WayControllerTest < ActionController::TestCase
assert_select "osm way[id=#{way.id}][version=#{way.version}][visible=#{way.visible}]", 1 assert_select "osm way[id=#{way.id}][version=#{way.version}][visible=#{way.visible}]", 1
# check that each node in the way appears once in the output as a # check that each node in the way appears once in the output as a
# reference and as the node element. note the slightly dodgy assumption # reference and as the node element.
# that nodes appear only once. this is currently the case with the
# fixtures, but it doesn't have to be.
way.nodes.each do |n| way.nodes.each do |n|
assert_select "osm way nd[ref=#{n.id}]", 1 count = (way.nodes - (way.nodes - [n])).length
assert_select "osm way nd[ref=#{n.id}]", count
assert_select "osm node[id=#{n.id}][version=#{n.version}][lat=#{n.lat}][lon=#{n.lon}]", 1 assert_select "osm node[id=#{n.id}][version=#{n.version}][lat=#{n.lat}][lon=#{n.lon}]", 1
end end
end end

View file

@ -4,7 +4,7 @@ class WayNodeTest < ActiveSupport::TestCase
api_fixtures api_fixtures
def test_way_nodes_count def test_way_nodes_count
assert_equal 4, WayNode.count assert_equal 6, WayNode.count
end end
end end

View file

@ -6,7 +6,7 @@ class WayTest < ActiveSupport::TestCase
# Check that we have the correct number of currnet ways in the db # Check that we have the correct number of currnet ways in the db
# This will need to updated whenever the current_ways.yml is updated # This will need to updated whenever the current_ways.yml is updated
def test_db_count def test_db_count
assert_equal 4, Way.count assert_equal 5, Way.count
end end
def test_bbox def test_bbox