Simplify element show paths in api tests
This commit is contained in:
parent
352e5de4b9
commit
ba2eb52054
5 changed files with 35 additions and 35 deletions
|
@ -2436,7 +2436,7 @@ module Api
|
||||||
assert_response :success, "can't create a new node"
|
assert_response :success, "can't create a new node"
|
||||||
node_id = @response.body.to_i
|
node_id = @response.body.to_i
|
||||||
|
|
||||||
get api_node_path(:id => node_id)
|
get api_node_path(node_id)
|
||||||
assert_response :success, "can't read back new node"
|
assert_response :success, "can't read back new node"
|
||||||
node_doc = XML::Parser.string(@response.body).parse
|
node_doc = XML::Parser.string(@response.body).parse
|
||||||
node_xml = node_doc.find("//osm/node").first
|
node_xml = node_doc.find("//osm/node").first
|
||||||
|
@ -2447,7 +2447,7 @@ module Api
|
||||||
node_xml["lon"] = rand.to_s
|
node_xml["lon"] = rand.to_s
|
||||||
node_xml["version"] = (i + 1).to_s
|
node_xml["version"] = (i + 1).to_s
|
||||||
|
|
||||||
put api_node_path(:id => node_id), :params => node_doc.to_s, :headers => auth_header
|
put api_node_path(node_id), :params => node_doc.to_s, :headers => auth_header
|
||||||
assert_response :success, "attempt #{i} should have succeeded"
|
assert_response :success, "attempt #{i} should have succeeded"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2456,7 +2456,7 @@ module Api
|
||||||
node_xml["lon"] = rand.to_s
|
node_xml["lon"] = rand.to_s
|
||||||
node_xml["version"] = offset.to_s
|
node_xml["version"] = offset.to_s
|
||||||
|
|
||||||
put api_node_path(:id => node_id), :params => node_doc.to_s, :headers => auth_header
|
put api_node_path(node_id), :params => node_doc.to_s, :headers => auth_header
|
||||||
assert_response :conflict, "final attempt should have failed"
|
assert_response :conflict, "final attempt should have failed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ module Api
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# check chat a non-existent node is not returned
|
# check chat a non-existent node is not returned
|
||||||
get api_node_path(:id => 0)
|
get api_node_path(0)
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ module Api
|
||||||
assert_require_public_data
|
assert_require_public_data
|
||||||
|
|
||||||
# this won't work since the node never existed
|
# this won't work since the node never existed
|
||||||
delete api_node_path(:id => 0), :headers => auth_header
|
delete api_node_path(0), :headers => auth_header
|
||||||
assert_require_public_data
|
assert_require_public_data
|
||||||
|
|
||||||
## these test whether nodes which are in-use can be deleted:
|
## these test whether nodes which are in-use can be deleted:
|
||||||
|
@ -241,7 +241,7 @@ module Api
|
||||||
# try to delete a node with a different ID
|
# try to delete a node with a different ID
|
||||||
other_node = create(:node)
|
other_node = create(:node)
|
||||||
xml = xml_for_node(other_node)
|
xml = xml_for_node(other_node)
|
||||||
delete api_node_path(node.id), :params => xml.to_s, :headers => auth_header
|
delete api_node_path(node), :params => xml.to_s, :headers => auth_header
|
||||||
assert_response :bad_request,
|
assert_response :bad_request,
|
||||||
"should not be able to delete a node with a different ID from the XML"
|
"should not be able to delete a node with a different ID from the XML"
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ module Api
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# this won't work since the node never existed
|
# this won't work since the node never existed
|
||||||
delete api_node_path(:id => 0), :headers => auth_header
|
delete api_node_path(0), :headers => auth_header
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
|
|
||||||
## these test whether nodes which are in-use can be deleted:
|
## these test whether nodes which are in-use can be deleted:
|
||||||
|
@ -360,7 +360,7 @@ module Api
|
||||||
# try and update a node without authorisation
|
# try and update a node without authorisation
|
||||||
# first try to update node without auth
|
# first try to update node without auth
|
||||||
xml = xml_for_node(node)
|
xml = xml_for_node(node)
|
||||||
put api_node_path(node.id), :params => xml.to_s, :headers => auth_header
|
put api_node_path(node), :params => xml.to_s, :headers => auth_header
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# setup auth
|
# setup auth
|
||||||
|
@ -548,7 +548,7 @@ module Api
|
||||||
assert_not_nil checknode, "node not found in data base after upload"
|
assert_not_nil checknode, "node not found in data base after upload"
|
||||||
|
|
||||||
# and grab it using the api
|
# and grab it using the api
|
||||||
get api_node_path(:id => nodeid)
|
get api_node_path(nodeid)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
apinode = Node.from_xml(@response.body)
|
apinode = Node.from_xml(@response.body)
|
||||||
assert_not_nil apinode, "downloaded node is nil, but shouldn't be"
|
assert_not_nil apinode, "downloaded node is nil, but shouldn't be"
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Api
|
||||||
xml_node["lat"] = precision((rand * 180) - 90).to_s
|
xml_node["lat"] = precision((rand * 180) - 90).to_s
|
||||||
xml_node["lon"] = precision((rand * 360) - 180).to_s
|
xml_node["lon"] = precision((rand * 360) - 180).to_s
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
put api_node_path(:id => nodeid), :params => xml_doc.to_s, :headers => auth_header
|
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
|
||||||
assert_response :forbidden, "Should have rejected node update"
|
assert_response :forbidden, "Should have rejected node update"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
end
|
end
|
||||||
|
@ -83,7 +83,7 @@ module Api
|
||||||
xml_tag["v"] = random_string
|
xml_tag["v"] = random_string
|
||||||
xml_node << xml_tag
|
xml_node << xml_tag
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
put api_node_path(:id => nodeid), :params => xml_doc.to_s, :headers => auth_header
|
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
|
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
|
@ -116,7 +116,7 @@ module Api
|
||||||
xml_node["lat"] = precision((rand * 180) - 90).to_s
|
xml_node["lat"] = precision((rand * 180) - 90).to_s
|
||||||
xml_node["lon"] = precision((rand * 360) - 180).to_s
|
xml_node["lon"] = precision((rand * 360) - 180).to_s
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
put api_node_path(:id => nodeid), :params => xml_doc.to_s, :headers => auth_header
|
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
|
||||||
assert_response :success
|
assert_response :success
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
end
|
end
|
||||||
|
@ -131,7 +131,7 @@ module Api
|
||||||
xml_tag["v"] = random_string
|
xml_tag["v"] = random_string
|
||||||
xml_node << xml_tag
|
xml_node << xml_tag
|
||||||
with_controller(NodesController.new) do
|
with_controller(NodesController.new) do
|
||||||
put api_node_path(:id => nodeid), :params => xml_doc.to_s, :headers => auth_header
|
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
|
||||||
assert_response :success,
|
assert_response :success,
|
||||||
"couldn't update node #{nodeid} (#{@response.body})"
|
"couldn't update node #{nodeid} (#{@response.body})"
|
||||||
xml_node["version"] = @response.body.to_s
|
xml_node["version"] = @response.body.to_s
|
||||||
|
@ -456,7 +456,7 @@ module Api
|
||||||
def check_current_version(node_id)
|
def check_current_version(node_id)
|
||||||
# get the current version of the node
|
# get the current version of the node
|
||||||
current_node = with_controller(NodesController.new) do
|
current_node = with_controller(NodesController.new) do
|
||||||
get api_node_path(:id => node_id)
|
get api_node_path(node_id)
|
||||||
assert_response :success, "cant get current node #{node_id}"
|
assert_response :success, "cant get current node #{node_id}"
|
||||||
Node.from_xml(@response.body)
|
Node.from_xml(@response.body)
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,7 +82,7 @@ module Api
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# check chat a non-existent relation is not returned
|
# check chat a non-existent relation is not returned
|
||||||
get api_relation_path(:id => 0)
|
get api_relation_path(0)
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ module Api
|
||||||
assert checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
get api_relation_path(:id => relationid)
|
get api_relation_path(relationid)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -315,7 +315,7 @@ module Api
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
|
|
||||||
get api_relation_path(:id => relationid)
|
get api_relation_path(relationid)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -343,7 +343,7 @@ module Api
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
|
|
||||||
get api_relation_path(:id => relationid)
|
get api_relation_path(relationid)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -371,7 +371,7 @@ module Api
|
||||||
assert checkrelation.visible,
|
assert checkrelation.visible,
|
||||||
"saved relation is not visible"
|
"saved relation is not visible"
|
||||||
# ok the relation is there but can we also retrieve it?
|
# ok the relation is there but can we also retrieve it?
|
||||||
get api_relation_path(:id => relationid)
|
get api_relation_path(relationid)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ module Api
|
||||||
auth_header = basic_authorization_header user.email, "test"
|
auth_header = basic_authorization_header user.email, "test"
|
||||||
with_relation(relation.id) do |rel|
|
with_relation(relation.id) do |rel|
|
||||||
update_changeset(rel, changeset.id)
|
update_changeset(rel, changeset.id)
|
||||||
put api_relation_path(:id => other_relation.id), :params => rel.to_s, :headers => auth_header
|
put api_relation_path(other_relation), :params => rel.to_s, :headers => auth_header
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -560,7 +560,7 @@ module Api
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# this won't work since the relation never existed
|
# this won't work since the relation never existed
|
||||||
delete api_relation_path(:id => 0), :headers => auth_header
|
delete api_relation_path(0), :headers => auth_header
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
## now set auth for the public user
|
## now set auth for the public user
|
||||||
|
@ -632,7 +632,7 @@ module Api
|
||||||
"should be able to delete a relation used in an old relation (#{@response.body})"
|
"should be able to delete a relation used in an old relation (#{@response.body})"
|
||||||
|
|
||||||
# this won't work since the relation never existed
|
# this won't work since the relation never existed
|
||||||
delete api_relation_path(:id => 0), :headers => auth_header
|
delete api_relation_path(0), :headers => auth_header
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -695,7 +695,7 @@ module Api
|
||||||
update_changeset(relation_xml, changeset_id)
|
update_changeset(relation_xml, changeset_id)
|
||||||
|
|
||||||
# upload the change
|
# upload the change
|
||||||
put api_relation_path(:id => relation.id), :params => relation_xml.to_s, :headers => auth_header
|
put api_relation_path(relation), :params => relation_xml.to_s, :headers => auth_header
|
||||||
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
|
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
|
||||||
|
|
||||||
# get it back and check the ordering
|
# get it back and check the ordering
|
||||||
|
@ -762,7 +762,7 @@ module Api
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
# get it back and check the ordering
|
# get it back and check the ordering
|
||||||
get api_relation_path(:id => relation_id)
|
get api_relation_path(relation_id)
|
||||||
assert_response :success, "can't read back the relation: #{@response.body}"
|
assert_response :success, "can't read back the relation: #{@response.body}"
|
||||||
check_ordering(doc, @response.body)
|
check_ordering(doc, @response.body)
|
||||||
|
|
||||||
|
@ -777,12 +777,12 @@ module Api
|
||||||
doc.find("//osm/relation").first["version"] = 1.to_s
|
doc.find("//osm/relation").first["version"] = 1.to_s
|
||||||
|
|
||||||
# upload the next version of the relation
|
# upload the next version of the relation
|
||||||
put api_relation_path(:id => relation_id), :params => doc.to_s, :headers => auth_header
|
put api_relation_path(relation_id), :params => doc.to_s, :headers => auth_header
|
||||||
assert_response :success, "can't update relation: #{@response.body}"
|
assert_response :success, "can't update relation: #{@response.body}"
|
||||||
assert_equal 2, @response.body.to_i
|
assert_equal 2, @response.body.to_i
|
||||||
|
|
||||||
# get it back again and check the ordering again
|
# get it back again and check the ordering again
|
||||||
get api_relation_path(:id => relation_id)
|
get api_relation_path(relation_id)
|
||||||
assert_response :success, "can't read back the relation: #{@response.body}"
|
assert_response :success, "can't read back the relation: #{@response.body}"
|
||||||
check_ordering(doc, @response.body)
|
check_ordering(doc, @response.body)
|
||||||
|
|
||||||
|
@ -829,7 +829,7 @@ module Api
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
# get it back and check the ordering
|
# get it back and check the ordering
|
||||||
get api_relation_path(:id => relation_id)
|
get api_relation_path(relation_id)
|
||||||
assert_response :success, "can't read back the relation: #{relation_id}"
|
assert_response :success, "can't read back the relation: #{relation_id}"
|
||||||
check_ordering(doc, @response.body)
|
check_ordering(doc, @response.body)
|
||||||
end
|
end
|
||||||
|
@ -862,7 +862,7 @@ module Api
|
||||||
relation_id = @response.body.to_i
|
relation_id = @response.body.to_i
|
||||||
|
|
||||||
# check the ordering in the current tables:
|
# check the ordering in the current tables:
|
||||||
get api_relation_path(:id => relation_id)
|
get api_relation_path(relation_id)
|
||||||
assert_response :success, "can't read back the relation: #{@response.body}"
|
assert_response :success, "can't read back the relation: #{@response.body}"
|
||||||
check_ordering(doc, @response.body)
|
check_ordering(doc, @response.body)
|
||||||
|
|
||||||
|
@ -1106,7 +1106,7 @@ module Api
|
||||||
# doc is returned.
|
# doc is returned.
|
||||||
def with_relation(id, ver = nil)
|
def with_relation(id, ver = nil)
|
||||||
if ver.nil?
|
if ver.nil?
|
||||||
get api_relation_path(:id => id)
|
get api_relation_path(id)
|
||||||
else
|
else
|
||||||
with_controller(OldRelationsController.new) do
|
with_controller(OldRelationsController.new) do
|
||||||
get api_old_relation_path(:id => id, :version => ver)
|
get api_old_relation_path(:id => id, :version => ver)
|
||||||
|
@ -1122,12 +1122,12 @@ module Api
|
||||||
# the parsed XML doc is returned.
|
# the parsed XML doc is returned.
|
||||||
def with_update(rel, headers)
|
def with_update(rel, headers)
|
||||||
rel_id = rel.find("//osm/relation").first["id"].to_i
|
rel_id = rel.find("//osm/relation").first["id"].to_i
|
||||||
put api_relation_path(:id => rel_id), :params => rel.to_s, :headers => headers
|
put api_relation_path(rel_id), :params => rel.to_s, :headers => headers
|
||||||
assert_response :success, "can't update relation: #{@response.body}"
|
assert_response :success, "can't update relation: #{@response.body}"
|
||||||
version = @response.body.to_i
|
version = @response.body.to_i
|
||||||
|
|
||||||
# now get the new version
|
# now get the new version
|
||||||
get api_relation_path(:id => rel_id)
|
get api_relation_path(rel_id)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
new_rel = xml_parse(@response.body)
|
new_rel = xml_parse(@response.body)
|
||||||
|
|
||||||
|
@ -1159,7 +1159,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
# now get the new version
|
# now get the new version
|
||||||
get api_relation_path(:id => rel_id)
|
get api_relation_path(rel_id)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
new_rel = xml_parse(@response.body)
|
new_rel = xml_parse(@response.body)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ module Api
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
|
|
||||||
# check chat a non-existent way is not returned
|
# check chat a non-existent way is not returned
|
||||||
get api_way_path(:id => 0)
|
get api_way_path(0)
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ module Api
|
||||||
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
|
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
|
||||||
|
|
||||||
# this won't work since the way never existed
|
# this won't work since the way never existed
|
||||||
delete api_way_path(:id => 0), :headers => auth_header
|
delete api_way_path(0), :headers => auth_header
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
### Now check with a public user
|
### Now check with a public user
|
||||||
|
@ -394,7 +394,7 @@ module Api
|
||||||
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
|
||||||
|
|
||||||
# this won't work since the way never existed
|
# this won't work since the way never existed
|
||||||
delete api_way_path(:id => 0), :params => xml.to_s, :headers => auth_header
|
delete api_way_path(0), :params => xml.to_s, :headers => auth_header
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue