+ def test_findgpx_bad_user
+ amf_content "findgpx", "/1", [1, "test@example.com:wrong"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 2, result.length
+ assert_equal -1, result[0]
+ assert_match /must be logged in/, result[1]
+
+ amf_content "findgpx", "/1", [1, "blocked@openstreetmap.org:test"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 2, result.length
+ assert_equal -1, result[0]
+ assert_match /access to the API has been blocked/, result[1]
+ end
+
+ def test_findgpx_by_id
+ trace = gpx_files(:anon_trace_file)
+
+ amf_content "findgpx", "/1", [trace.id, "test@example.com:test"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 3, result.length
+ assert_equal 0, result[0]
+ assert_equal "", result[1]
+ traces = result[2]
+ assert_equal 1, traces.length
+ assert_equal 3, traces[0].length
+ assert_equal trace.id, traces[0][0]
+ assert_equal trace.name, traces[0][1]
+ assert_equal trace.description, traces[0][2]
+ end
+
+ def test_findgpx_by_name
+ amf_content "findgpx", "/1", ["Trace", "test@example.com:test"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ # find by name fails as it uses mysql text search syntax...
+ assert_equal 2, result.length
+ assert_equal -2, result[0]
+ end
+
+ def test_findrelations_by_id
+ relation = current_relations(:relation_with_versions)
+
+ amf_content "findrelations", "/1", [relation.id]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 1, result.length
+ assert_equal 4, result[0].length
+ assert_equal relation.id, result[0][0]
+ assert_equal relation.tags, result[0][1]
+ assert_equal relation.members, result[0][2]
+ assert_equal relation.version, result[0][3]
+
+ amf_content "findrelations", "/1", [999999]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 0, result.length
+ end
+
+ def test_findrelations_by_tags
+ visible_relation = current_relations(:visible_relation)
+ used_relation = current_relations(:used_relation)
+
+ amf_content "findrelations", "/1", ["yes"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1").sort
+
+ assert_equal 2, result.length
+ assert_equal 4, result[0].length
+ assert_equal visible_relation.id, result[0][0]
+ assert_equal visible_relation.tags, result[0][1]
+ assert_equal visible_relation.members, result[0][2]
+ assert_equal visible_relation.version, result[0][3]
+ assert_equal 4, result[1].length
+ assert_equal used_relation.id, result[1][0]
+ assert_equal used_relation.tags, result[1][1]
+ assert_equal used_relation.members, result[1][2]
+ assert_equal used_relation.version, result[1][3]
+
+ amf_content "findrelations", "/1", ["no"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1").sort
+
+ assert_equal 0, result.length
+ end
+
+ def test_getpoi_without_timestamp
+ node = current_nodes(:node_with_versions)
+
+ amf_content "getpoi", "/1", [node.id, ""]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 7, result.length
+ assert_equal 0, result[0]
+ assert_equal "", result[1]
+ assert_equal node.id, result[2]
+ assert_equal node.lon, result[3]
+ assert_equal node.lat, result[4]
+ assert_equal node.tags, result[5]
+ assert_equal node.version, result[6]
+
+ amf_content "getpoi", "/1", [999999, ""]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 3, result.length
+ assert_equal -4, result[0]
+ assert_equal "node", result[1]
+ assert_equal 999999, result[2]
+ end
+
+ def test_getpoi_with_timestamp
+ node = nodes(:node_with_versions_v2)
+ current_node = current_nodes(:node_with_versions)
+
+ amf_content "getpoi", "/1", [node.node_id, node.timestamp.xmlschema]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 7, result.length
+ assert_equal 0, result[0]
+ assert_equal "", result[1]
+ assert_equal node.node_id, result[2]
+ assert_equal node.lon, result[3]
+ assert_equal node.lat, result[4]
+ assert_equal node.tags, result[5]
+ assert_equal current_node.version, result[6]
+
+ amf_content "getpoi", "/1", [node.node_id, "2000-01-01T00:00:00Z"]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 3, result.length
+ assert_equal -4, result[0]
+ assert_equal "node", result[1]
+ assert_equal node.node_id, result[2]
+
+ amf_content "getpoi", "/1", [999999, Time.now.xmlschema]
+ post :amf_read
+ assert_response :success
+ amf_parse_response
+ result = amf_result("/1")
+
+ assert_equal 3, result.length
+ assert_equal -4, result[0]
+ assert_equal "node", result[1]
+ assert_equal 999999, result[2]
+ end
+