]> git.openstreetmap.org Git - rails.git/blob - test/functional/amf_controller_test.rb
Extend geocoder to support additional lat/lon formats
[rails.git] / test / functional / amf_controller_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'stringio'
3 include Potlatch
4
5 class AmfControllerTest < ActionController::TestCase
6   api_fixtures
7
8   ##
9   # test all routes which lead to this controller
10   def test_routes
11     assert_routing(
12       { :path => "/api/0.6/amf/read", :method => :post },
13       { :controller => "amf", :action => "amf_read" }
14     )
15     assert_routing(
16       { :path => "/api/0.6/amf/write", :method => :post },
17       { :controller => "amf", :action => "amf_write" }
18     )
19   end
20
21   def test_getway
22     # check a visible way
23     id = current_ways(:visible_way).id
24     amf_content "getway", "/1", [id]
25     post :amf_read
26     assert_response :success
27     amf_parse_response                                         
28     way = amf_result("/1")
29     assert_equal way[0], 0
30     assert_equal way[2], id
31   end
32
33   def test_getway_invisible
34     # check an invisible way
35     id = current_ways(:invisible_way).id
36     amf_content "getway", "/1", [id]
37     post :amf_read
38     assert_response :success
39     amf_parse_response
40     way = amf_result("/1")
41     assert_equal way[0], -4
42     assert_equal way[1], "way"
43     assert_equal way[2], id
44     assert way[3].nil? and way[4].nil?
45   end
46
47   def test_getway_nonexistent
48     # check chat a non-existent way is not returned
49     amf_content "getway", "/1", [0]
50     post :amf_read
51     assert_response :success
52     amf_parse_response
53     way = amf_result("/1")
54     assert_equal way[0], -4
55     assert_equal way[1], "way"
56     assert_equal way[2], 0
57     assert way[3].nil? and way[4].nil?
58   end
59
60   def test_whichways
61     node = current_nodes(:used_node_1)
62     minlon = node.lon-0.1
63     minlat = node.lat-0.1
64     maxlon = node.lon+0.1
65     maxlat = node.lat+0.1
66     amf_content "whichways", "/1", [minlon, minlat, maxlon, maxlat]
67     post :amf_read
68     assert_response :success
69     amf_parse_response 
70
71     # check contents of message
72     map = amf_result "/1"
73     assert_equal 0, map[0], 'map error code should be 0'
74     assert_equal "", map[1], 'map error text should be empty'
75
76     # check the formatting of the message
77     assert_equal 5, map.length, 'map should have length 5'
78     assert_equal Array, map[2].class, 'map "ways" element should be an array'
79     assert_equal Array, map[3].class, 'map "nodes" element should be an array'
80     assert_equal Array, map[4].class, 'map "relations" element should be an array'
81     map[2].each do |w|
82       assert_equal 2, w.length, 'way should be (id, version) pair'
83       assert w[0] == w[0].floor, 'way ID should be an integer'
84       assert w[1] == w[1].floor, 'way version should be an integer'
85     end
86
87     map[3].each do |n|
88       assert_equal 5, w.length, 'node should be (id, lat, lon, [tags], version) tuple'
89       assert n[0] == n[0].floor, 'node ID should be an integer'
90       assert n[1] >= minlat - 0.01, 'node lat should be greater than min'
91       assert n[1] <= maxlat - 0.01, 'node lat should be less than max'
92       assert n[2] >= minlon - 0.01, 'node lon should be greater than min'
93       assert n[2] <= maxlon - 0.01, 'node lon should be less than max'
94       assert_equal Array, a[3].class, 'node tags should be array'
95       assert n[4] == n[4].floor, 'node version should be an integer'
96     end
97
98     map[4].each do |r|
99       assert_equal 2, r.length, 'relation should be (id, version) pair'
100       assert r[0] == r[0].floor, 'relation ID should be an integer'
101       assert r[1] == r[1].floor, 'relation version should be an integer'
102     end
103
104     # TODO: looks like amf_controller changed since this test was written
105     # so someone who knows what they're doing should check this!
106     ways = map[2].collect { |x| x[0] }
107     assert ways.include?(current_ways(:used_way).id),
108       "map should include used way"
109     assert !ways.include?(current_ways(:invisible_way).id),
110       'map should not include deleted way'
111   end
112
113   ##
114   # checks that too-large a bounding box will not be served.
115   def test_whichways_toobig
116     bbox = [-0.1,-0.1,1.1,1.1]
117     check_bboxes_are_bad [bbox] do |map,bbox|
118       assert_boundary_error map, " The server said: The maximum bbox size is 0.25, and your request was too large. Either request a smaller area, or use planet.osm"
119     end
120   end
121
122   ##
123   # checks that an invalid bounding box will not be served. in this case
124   # one with max < min latitudes.
125   #
126   # NOTE: the controller expands the bbox by 0.01 in each direction!
127   def test_whichways_badlat
128     bboxes = [[0,0.1,0.1,0], [-0.1,80,0.1,70], [0.24,54.35,0.25,54.33]]
129     check_bboxes_are_bad bboxes do |map, bbox|
130       assert_boundary_error map, " The server said: The minimum latitude must be less than the maximum latitude, but it wasn't", bbox.inspect
131     end
132   end
133
134   ##
135   # same as test_whichways_badlat, but for longitudes
136   #
137   # NOTE: the controller expands the bbox by 0.01 in each direction!
138   def test_whichways_badlon
139     bboxes = [[80,-0.1,70,0.1], [54.35,0.24,54.33,0.25]]
140     check_bboxes_are_bad bboxes do |map, bbox|
141       assert_boundary_error map, " The server said: The minimum longitude must be less than the maximum longitude, but it wasn't", bbox.inspect
142     end
143   end
144
145   def test_whichways_deleted
146     node = current_nodes(:used_node_1)
147     minlon = node.lon-0.1
148     minlat = node.lat-0.1
149     maxlon = node.lon+0.1
150     maxlat = node.lat+0.1
151     amf_content "whichways_deleted", "/1", [minlon, minlat, maxlon, maxlat]
152     post :amf_read
153     assert_response :success
154     amf_parse_response
155
156     # check contents of message
157     map = amf_result "/1"
158     assert_equal 0, map[0], 'first map element should be 0'
159     assert_equal "", map[1], 'second map element should be an empty string'
160     assert_equal Array, map[2].class, 'third map element should be an array'
161     # TODO: looks like amf_controller changed since this test was written
162     # so someone who knows what they're doing should check this!
163     assert !map[2].include?(current_ways(:used_way).id),
164       "map should not include used way"
165     assert map[2].include?(current_ways(:invisible_way).id),
166       'map should include deleted way'
167   end
168
169   def test_whichways_deleted_toobig
170     bbox = [-0.1,-0.1,1.1,1.1]
171     amf_content "whichways_deleted", "/1", bbox
172     post :amf_read
173     assert_response :success
174     amf_parse_response 
175
176     map = amf_result "/1"
177     assert_deleted_boundary_error map, " The server said: The maximum bbox size is 0.25, and your request was too large. Either request a smaller area, or use planet.osm"
178   end
179
180   def test_getrelation
181     id = current_relations(:visible_relation).id
182     amf_content "getrelation", "/1", [id]
183     post :amf_read
184     assert_response :success
185     amf_parse_response
186     rel = amf_result("/1")
187     assert_equal rel[0], 0
188     assert_equal rel[2], id
189   end
190
191   def test_getrelation_invisible
192     id = current_relations(:invisible_relation).id
193     amf_content "getrelation", "/1", [id]
194     post :amf_read
195     assert_response :success
196     amf_parse_response
197     rel = amf_result("/1")
198     assert_equal rel[0], -4
199     assert_equal rel[1], "relation"
200     assert_equal rel[2], id
201     assert rel[3].nil? and rel[4].nil?
202   end
203
204   def test_getrelation_nonexistent
205     id = 0
206     amf_content "getrelation", "/1", [id]
207     post :amf_read
208     assert_response :success
209     amf_parse_response
210     rel = amf_result("/1")
211     assert_equal rel[0], -4
212     assert_equal rel[1], "relation"
213     assert_equal rel[2], id
214     assert rel[3].nil? and rel[4].nil?
215   end
216
217   def test_getway_old
218     # try to get the last visible version (specified by <0) (should be current version)
219     latest = current_ways(:way_with_versions)
220     # NOTE: looks from the API changes that this now expects a timestamp
221     # instead of a version number...
222     # try to get version 1
223     v1 = ways(:way_with_versions_v1)
224     { latest.id => '', 
225       v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
226     }.each do |id, t|
227       amf_content "getway_old", "/1", [id, t]
228       post :amf_read      
229       assert_response :success
230       amf_parse_response
231       returned_way = amf_result("/1")
232       assert_equal 0, returned_way[0]
233       assert_equal id, returned_way[2]
234       # API returns the *latest* version, even for old ways...
235       assert_equal latest.version, returned_way[5]
236     end
237   end
238   
239   ##
240   # test that the server doesn't fall over when rubbish is passed
241   # into the method args.
242   def test_getway_old_invalid
243     way_id = current_ways(:way_with_versions).id
244     { "foo"  => "bar",
245       way_id => "not a date",
246       way_id => "2009-03-25 00:00:00", # <- wrong format
247       way_id => "0 Jan 2009 00:00:00", # <- invalid date
248       -1     => "1 Jan 2009 00:00:00"  # <- invalid ID
249     }.each do |id, t|
250       amf_content "getway_old", "/1", [id, t]
251       post :amf_read
252       assert_response :success
253       amf_parse_response
254       returned_way = amf_result("/1")
255       assert_equal -1, returned_way[0]
256       assert returned_way[3].nil?
257       assert returned_way[4].nil?
258       assert returned_way[5].nil?
259     end
260   end
261
262   def test_getway_old_nonexistent
263     # try to get the last version+10 (shoudn't exist)
264     v1 = ways(:way_with_versions_v1)
265     # try to get last visible version of non-existent way
266     # try to get specific version of non-existent way
267     [[0, ''], 
268      [0, '1 Jan 1970, 00:00:00'], 
269      [v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]
270     ].each do |id, t|
271       amf_content "getway_old", "/1", [id, t]
272       post :amf_read
273       assert_response :success
274       amf_parse_response
275       returned_way = amf_result("/1")
276       assert_equal -1, returned_way[0]
277       assert returned_way[3].nil?
278       assert returned_way[4].nil?
279       assert returned_way[5].nil?
280     end
281   end
282
283   def test_getway_history
284     latest = current_ways(:way_with_versions)
285     oldest = ways(:way_with_versions_v1)
286
287     amf_content "getway_history", "/1", [latest.id]
288     post :amf_read
289     assert_response :success
290     amf_parse_response
291     history = amf_result("/1")
292
293     # ['way',wayid,history]
294     assert_equal 'way', history[0]
295     assert_equal latest.id, history[1] 
296     # We use dates rather than version numbers here, because you might
297     # have moved a node within a way (i.e. way version not incremented).
298     # The timestamp is +1 because we say "give me the revision of 15:33:02",
299     # but that might actually include changes at 15:33:02.457.
300     assert_equal (latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), history[2].first[0]
301     assert_equal (oldest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), history[2].last[0]
302   end
303
304   def test_getway_history_nonexistent
305     amf_content "getway_history", "/1", [0]
306     post :amf_read
307     assert_response :success
308     amf_parse_response
309     history = amf_result("/1")
310
311     # ['way',wayid,history]
312     assert_equal history[0], 'way'
313     assert_equal history[1], 0
314     assert history[2].empty?
315   end
316
317   def test_getnode_history
318     latest = current_nodes(:node_with_versions)
319     amf_content "getnode_history", "/1", [latest.id]
320     post :amf_read
321     assert_response :success
322     amf_parse_response
323     history = amf_result("/1")
324
325     # ['node',nodeid,history]
326     # note that (as per getway_history) we actually round up
327     # to the next second
328     assert_equal history[0], 'node', 
329       'first element should be "node"'
330     assert_equal history[1], latest.id,
331       'second element should be the input node ID'
332     assert_equal history[2].first[0], 
333       (latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
334       'first element in third element (array) should be the latest version'
335     assert_equal history[2].last[0], 
336       (nodes(:node_with_versions_v1).timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
337       'last element in third element (array) should be the initial version'
338   end
339
340   def test_getnode_history_nonexistent
341     amf_content "getnode_history", "/1", [0]
342     post :amf_read
343     assert_response :success
344     amf_parse_response
345     history = amf_result("/1")
346
347     # ['node',nodeid,history]
348     assert_equal history[0], 'node'
349     assert_equal history[1], 0
350     assert history[2].empty?
351   end
352
353   # ************************************************************
354   # AMF Write tests
355   def test_putpoi_update_valid
356     nd = current_nodes(:visible_node)
357     cs_id = changesets(:public_user_first_change).id
358     amf_content "putpoi", "/1", ["test@example.com:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]
359     post :amf_write
360     assert_response :success
361     amf_parse_response
362     result = amf_result("/1")
363     
364     assert_equal 0, result[0]
365     assert_equal "", result[1]
366     assert_equal nd.id, result[2]
367     assert_equal nd.id, result[3]
368     assert_equal nd.version+1, result[4]
369     
370     # Now try to update again, with a different lat/lon, using the updated version number
371     lat = nd.lat+0.1
372     lon = nd.lon-0.1
373     amf_content "putpoi", "/2", ["test@example.com:test", cs_id, nd.version+1, nd.id, lon, lat, nd.tags, nd.visible]
374     post :amf_write
375     assert_response :success
376     amf_parse_response
377     result = amf_result("/2")
378     
379     assert_equal 0, result[0]
380     assert_equal "", result[1]
381     assert_equal nd.id, result[2]
382     assert_equal nd.id, result[3]
383     assert_equal nd.version+2, result[4]
384   end
385   
386   # Check that we can create a no valid poi
387   # Using similar method for the node controller test
388   def test_putpoi_create_valid
389     # This node has no tags
390     nd = Node.new
391     # create a node with random lat/lon
392     lat = rand(100)-50 + rand
393     lon = rand(100)-50 + rand
394     # normal user has a changeset open
395     changeset = changesets(:public_user_first_change)
396     
397     amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, {}, nil]
398     post :amf_write
399     assert_response :success
400     amf_parse_response
401     result = amf_result("/1")
402     
403     # check the array returned by the amf
404     assert_equal 5, result.size
405     assert_equal 0, result[0], "expected to get the status ok from the amf"
406     assert_equal 0, result[2], "The old id should be 0"
407     assert result[3] > 0, "The new id should be greater than 0"
408     assert_equal 1, result[4], "The new version should be 1"
409     
410     # Finally check that the node that was saved has saved the data correctly 
411     # in both the current and history tables
412     # First check the current table
413     current_node = Node.find(result[3].to_i)
414     assert_in_delta lat, current_node.lat, 0.00001, "The latitude was not retreieved correctly"
415     assert_in_delta lon, current_node.lon, 0.00001, "The longitude was not retreived correctly"
416     assert_equal 0, current_node.tags.size, "There seems to be a tag that has been added to the node"
417     assert_equal result[4], current_node.version, "The version returned, is different to the one returned by the amf"
418     # Now check the history table
419     historic_nodes = Node.find(:all, :conditions => { :id => result[3] })
420     assert_equal 1, historic_nodes.size, "There should only be one historic node created"
421     first_historic_node = historic_nodes.first
422     assert_in_delta lat, first_historic_node.lat, 0.00001, "The latitude was not retreived correctly"
423     assert_in_delta lon, first_historic_node.lon, 0.00001, "The longitude was not retreuved correctly"
424     assert_equal 0, first_historic_node.tags.size, "There seems to be a tag that have been attached to this node"
425     assert_equal result[4], first_historic_node.version, "The version returned, is different to the one returned by the amf"
426     
427     ####
428     # This node has some tags
429     tnd = Node.new
430     # create a node with random lat/lon
431     lat = rand(100)-50 + rand
432     lon = rand(100)-50 + rand
433     # normal user has a changeset open
434     changeset = changesets(:public_user_first_change)
435     
436     amf_content "putpoi", "/2", ["test@example.com:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil]
437     post :amf_write
438     assert_response :success
439     amf_parse_response
440     result = amf_result("/2")
441
442     # check the array returned by the amf
443     assert_equal 5, result.size
444     assert_equal 0, result[0], "Expected to get the status ok in the amf"
445     assert_equal 0, result[2], "The old id should be 0"
446     assert result[3] > 0, "The new id should be greater than 0"
447     assert_equal 1, result[4], "The new version should be 1"
448     
449     # Finally check that the node that was saved has saved the data correctly 
450     # in both the current and history tables
451     # First check the current table
452     current_node = Node.find(result[3].to_i)
453     assert_in_delta lat, current_node.lat, 0.00001, "The latitude was not retreieved correctly"
454     assert_in_delta lon, current_node.lon, 0.00001, "The longitude was not retreived correctly"
455     assert_equal 2, current_node.tags.size, "There seems to be a tag that has been added to the node"
456     assert_equal({ "key" => "value", "ping" => "pong" }, current_node.tags, "tags are different")
457     assert_equal result[4], current_node.version, "The version returned, is different to the one returned by the amf"
458     # Now check the history table
459     historic_nodes = Node.find(:all, :conditions => { :id => result[3] })
460     assert_equal 1, historic_nodes.size, "There should only be one historic node created"
461     first_historic_node = historic_nodes.first
462     assert_in_delta lat, first_historic_node.lat, 0.00001, "The latitude was not retreived correctly"
463     assert_in_delta lon, first_historic_node.lon, 0.00001, "The longitude was not retreuved correctly"
464     assert_equal 2, first_historic_node.tags.size, "There seems to be a tag that have been attached to this node"
465     assert_equal({ "key" => "value", "ping" => "pong" }, first_historic_node.tags, "tags are different")
466     assert_equal result[4], first_historic_node.version, "The version returned, is different to the one returned by the amf"
467   end
468   
469   # try creating a POI with rubbish in the tags
470   def test_putpoi_create_with_control_chars
471     # This node has no tags
472     nd = Node.new
473     # create a node with random lat/lon
474     lat = rand(100)-50 + rand
475     lon = rand(100)-50 + rand
476     # normal user has a changeset open
477     changeset = changesets(:public_user_first_change)
478     
479     mostly_invalid = (0..31).to_a.map {|i| i.chr}.join
480     tags = { "something" => "foo#{mostly_invalid}bar" }
481       
482     amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, tags, nil]
483     post :amf_write
484     assert_response :success
485     amf_parse_response
486     result = amf_result("/1")
487       
488     # check the array returned by the amf
489     assert_equal 5, result.size
490     assert_equal 0, result[0], "Expected to get the status ok in the amf"
491     assert_equal 0, result[2], "The old id should be 0"
492     assert result[3] > 0, "The new id should be greater than 0"
493     assert_equal 1, result[4], "The new version should be 1"
494     
495     # Finally check that the node that was saved has saved the data correctly 
496     # in both the current and history tables
497     # First check the current table
498     current_node = Node.find(result[3].to_i)
499     assert_equal 1, current_node.tags.size, "There seems to be a tag that has been added to the node"
500     assert_equal({ "something" => "foo\t\n\rbar" }, current_node.tags, "tags were not fixed correctly")
501     assert_equal result[4], current_node.version, "The version returned, is different to the one returned by the amf"
502   end
503
504   # try creating a POI with rubbish in the tags
505   def test_putpoi_create_with_invalid_utf8
506     # This node has no tags
507     nd = Node.new
508     # create a node with random lat/lon
509     lat = rand(100)-50 + rand
510     lon = rand(100)-50 + rand
511     # normal user has a changeset open
512     changeset = changesets(:public_user_first_change)
513     
514     invalid = "\xc0\xc0"
515     tags = { "something" => "foo#{invalid}bar" }
516       
517     amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, tags, nil]
518     post :amf_write
519     assert_response :success
520     amf_parse_response
521     result = amf_result("/1")
522
523     assert_equal 2, result.size
524     assert_equal -1, result[0], "Expected to get the status FAIL in the amf"
525     assert_equal "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1.", result[1] 
526   end
527       
528   def test_putpoi_delete_valid
529     
530   end
531   
532   def test_putpoi_delete_already_deleted
533     
534   end
535   
536   def test_putpoi_delete_not_found
537     
538   end
539   
540   def test_putpoi_invalid_latlon
541     
542   end
543
544   def test_startchangeset_invalid_xmlchar_comment
545     invalid = "\035\022"
546     comment = "foo#{invalid}bar"
547       
548     amf_content "startchangeset", "/1", ["test@example.com:test", Hash.new, nil, comment, 1]
549     post :amf_write
550     assert_response :success
551     amf_parse_response
552     result = amf_result("/1")
553
554     assert_equal 3, result.size, result.inspect
555     assert_equal 0, result[0]
556     new_cs_id = result[2].to_i
557
558     cs = Changeset.find(new_cs_id)
559     assert_equal "foobar", cs.tags["comment"]
560   end
561
562   # ************************************************************
563   # AMF Helper functions
564
565   # Get the result record for the specified ID
566   # It's an assertion FAIL if the record does not exist
567   def amf_result ref
568     assert @amf_result.has_key?("#{ref}/onResult")
569     @amf_result["#{ref}/onResult"]
570   end
571
572   # Encode the AMF message to invoke "target" with parameters as
573   # the passed data. The ref is used to retrieve the results.
574   def amf_content(target, ref, data)
575     a,b=1.divmod(256)
576     c = StringIO.new()
577     c.write 0.chr+0.chr   # version 0
578     c.write 0.chr+0.chr   # n headers
579     c.write a.chr+b.chr   # n bodies
580     c.write AMF.encodestring(target)
581     c.write AMF.encodestring(ref)
582     c.write [-1].pack("N")
583     c.write AMF.encodevalue(data)
584
585     @request.env["RAW_POST_DATA"] = c.string
586   end
587
588   # Parses the @response object as an AMF messsage.
589   # The result is a hash of message_ref => data.
590   # The attribute @amf_result is initialised to this hash.
591   def amf_parse_response
592     req = StringIO.new(@response.body)
593
594     req.read(2)   # version
595
596     # parse through any headers
597         headers=AMF.getint(req)                                 # Read number of headers
598         headers.times do                                                # Read each header
599           name=AMF.getstring(req)                               #  |
600           req.getc                                                              #  | skip boolean
601           value=AMF.getvalue(req)                               #  |
602         end
603
604     # parse through responses
605     results = {}
606     bodies=AMF.getint(req)                                      # Read number of bodies
607         bodies.times do                                                 # Read each body
608           message=AMF.getstring(req)                    #  | get message name
609           index=AMF.getstring(req)                              #  | get index in response sequence
610           bytes=AMF.getlong(req)                                #  | get total size in bytes
611           args=AMF.getvalue(req)                                #  | get response (probably an array)
612       results[message] = args
613     end
614     @amf_result = results
615     results
616   end
617
618   ##
619   # given an array of bounding boxes (each an array of 4 floats), call the
620   # AMF "whichways" controller for each and pass the result back to the
621   # caller's block for assertion testing.
622   def check_bboxes_are_bad(bboxes)
623     bboxes.each do |bbox|
624       amf_content "whichways", "/1", bbox
625       post :amf_read
626       assert_response :success
627       amf_parse_response
628
629       # pass the response back to the caller's block to be tested
630       # against what the caller expected.
631       map = amf_result "/1"
632       yield map, bbox
633     end
634   end
635   
636   # this should be what AMF controller returns when the bbox of a
637   # whichways request is invalid or too large.
638   def assert_boundary_error(map, msg=nil, error_hint=nil)
639     expected_map = [-2, "Sorry - I can't get the map for that area.#{msg}"]
640     assert_equal expected_map, map, "AMF controller should have returned an error. (#{error_hint})"
641   end
642
643   # this should be what AMF controller returns when the bbox of a
644   # whichways_deleted request is invalid or too large.
645   def assert_deleted_boundary_error(map, msg=nil, error_hint=nil)
646     expected_map = [-2, "Sorry - I can't get the map for that area.#{msg}"]
647     assert_equal expected_map, map, "AMF controller should have returned an error. (#{error_hint})"
648   end
649 end