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"
|
||||
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"
|
||||
node_doc = XML::Parser.string(@response.body).parse
|
||||
node_xml = node_doc.find("//osm/node").first
|
||||
|
@ -2447,7 +2447,7 @@ module Api
|
|||
node_xml["lon"] = rand.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"
|
||||
end
|
||||
|
||||
|
@ -2456,7 +2456,7 @@ module Api
|
|||
node_xml["lon"] = rand.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"
|
||||
end
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ module Api
|
|||
assert_response :gone
|
||||
|
||||
# check chat a non-existent node is not returned
|
||||
get api_node_path(:id => 0)
|
||||
get api_node_path(0)
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ module Api
|
|||
assert_require_public_data
|
||||
|
||||
# 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
|
||||
|
||||
## 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
|
||||
other_node = create(: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,
|
||||
"should not be able to delete a node with a different ID from the XML"
|
||||
|
||||
|
@ -266,7 +266,7 @@ module Api
|
|||
assert_response :gone
|
||||
|
||||
# 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
|
||||
|
||||
## these test whether nodes which are in-use can be deleted:
|
||||
|
@ -360,7 +360,7 @@ module Api
|
|||
# try and update a node without authorisation
|
||||
# first try to update node without auth
|
||||
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
|
||||
|
||||
# setup auth
|
||||
|
@ -548,7 +548,7 @@ module Api
|
|||
assert_not_nil checknode, "node not found in data base after upload"
|
||||
|
||||
# and grab it using the api
|
||||
get api_node_path(:id => nodeid)
|
||||
get api_node_path(nodeid)
|
||||
assert_response :success
|
||||
apinode = Node.from_xml(@response.body)
|
||||
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["lon"] = precision((rand * 360) - 180).to_s
|
||||
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"
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ module Api
|
|||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
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 #{nodeid} (#{@response.body}) with forbidden"
|
||||
xml_node["version"] = @response.body.to_s
|
||||
|
@ -116,7 +116,7 @@ module Api
|
|||
xml_node["lat"] = precision((rand * 180) - 90).to_s
|
||||
xml_node["lon"] = precision((rand * 360) - 180).to_s
|
||||
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
|
||||
xml_node["version"] = @response.body.to_s
|
||||
end
|
||||
|
@ -131,7 +131,7 @@ module Api
|
|||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
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,
|
||||
"couldn't update node #{nodeid} (#{@response.body})"
|
||||
xml_node["version"] = @response.body.to_s
|
||||
|
@ -456,7 +456,7 @@ module Api
|
|||
def check_current_version(node_id)
|
||||
# get the current version of the node
|
||||
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}"
|
||||
Node.from_xml(@response.body)
|
||||
end
|
||||
|
|
|
@ -82,7 +82,7 @@ module Api
|
|||
assert_response :gone
|
||||
|
||||
# check chat a non-existent relation is not returned
|
||||
get api_relation_path(:id => 0)
|
||||
get api_relation_path(0)
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
|
@ -286,7 +286,7 @@ module Api
|
|||
assert checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# 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
|
||||
|
||||
###
|
||||
|
@ -315,7 +315,7 @@ module Api
|
|||
"saved relation is not visible"
|
||||
# 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
|
||||
|
||||
###
|
||||
|
@ -343,7 +343,7 @@ module Api
|
|||
"saved relation is not visible"
|
||||
# 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
|
||||
|
||||
###
|
||||
|
@ -371,7 +371,7 @@ module Api
|
|||
assert checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -453,7 +453,7 @@ module Api
|
|||
auth_header = basic_authorization_header user.email, "test"
|
||||
with_relation(relation.id) do |rel|
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -560,7 +560,7 @@ module Api
|
|||
assert_response :forbidden
|
||||
|
||||
# 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
|
||||
|
||||
## 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})"
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -695,7 +695,7 @@ module Api
|
|||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
# 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}"
|
||||
|
||||
# get it back and check the ordering
|
||||
|
@ -762,7 +762,7 @@ module Api
|
|||
relation_id = @response.body.to_i
|
||||
|
||||
# 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}"
|
||||
check_ordering(doc, @response.body)
|
||||
|
||||
|
@ -777,12 +777,12 @@ module Api
|
|||
doc.find("//osm/relation").first["version"] = 1.to_s
|
||||
|
||||
# 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_equal 2, @response.body.to_i
|
||||
|
||||
# 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}"
|
||||
check_ordering(doc, @response.body)
|
||||
|
||||
|
@ -829,7 +829,7 @@ module Api
|
|||
relation_id = @response.body.to_i
|
||||
|
||||
# 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}"
|
||||
check_ordering(doc, @response.body)
|
||||
end
|
||||
|
@ -862,7 +862,7 @@ module Api
|
|||
relation_id = @response.body.to_i
|
||||
|
||||
# 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}"
|
||||
check_ordering(doc, @response.body)
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ module Api
|
|||
# doc is returned.
|
||||
def with_relation(id, ver = nil)
|
||||
if ver.nil?
|
||||
get api_relation_path(:id => id)
|
||||
get api_relation_path(id)
|
||||
else
|
||||
with_controller(OldRelationsController.new) do
|
||||
get api_old_relation_path(:id => id, :version => ver)
|
||||
|
@ -1122,12 +1122,12 @@ module Api
|
|||
# the parsed XML doc is returned.
|
||||
def with_update(rel, headers)
|
||||
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}"
|
||||
version = @response.body.to_i
|
||||
|
||||
# now get the new version
|
||||
get api_relation_path(:id => rel_id)
|
||||
get api_relation_path(rel_id)
|
||||
assert_response :success
|
||||
new_rel = xml_parse(@response.body)
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ module Api
|
|||
end
|
||||
|
||||
# now get the new version
|
||||
get api_relation_path(:id => rel_id)
|
||||
get api_relation_path(rel_id)
|
||||
assert_response :success
|
||||
new_rel = xml_parse(@response.body)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ module Api
|
|||
assert_response :gone
|
||||
|
||||
# check chat a non-existent way is not returned
|
||||
get api_way_path(:id => 0)
|
||||
get api_way_path(0)
|
||||
assert_response :not_found
|
||||
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"
|
||||
|
||||
# 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
|
||||
|
||||
### 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
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue