Testserver rb
From OpenStreetMap
THIS SCRIPT MAY HARM THE DATABASE.
Do not run it on servers with production database!
In Subversion, /script/testserver.rb is a test script that runs several calls to an API at localhost. The script is a sequential, fail-fast, integration test (this means: if something fails, the script aborts).
Setup
The script assumes, that an user "foo@bar.baz" has been created with password "foobar". If you work with the current ruby-based server implementation, run the following sql to create such an user:
INSERT INTO `users` VALUES ('foo@bar.baz',1,'5iLWPXjMnALYVK3EU73EEXu39dCQxF',1,'3858f62230ac3c915f300c664312c63f','2006-07-21 00:00:00','2006-07-22 00:00:00',);
After the user has been created, just run the script:
ruby testserver.rb
Test Cases
The following cases will be tested (when the script is finished ;). Cases in italic will be skipped out, because the server fails in them yet ;).
| Use case | Expected result |
| creating a new node | retrieved id != 0 |
| creating another node | id != 0 and != id of former created node |
| creating a line segment between both nodes | retrieve id != 0 |
| try to remove first node | error that node is in use |
| create a way out of the segment | retrieve id != 0 |
| get both nodes by id | both node xml structures. lat/lon are correct |
| get the first node by id | correct node xml structure |
| get the segment by id | correct segment xml structure |
| get the way by id | correct way xml structure |
| do a map request covering both nodes in area | get both nodes, the segment and the way |
| do a map request covering only one node | get at least the covered node*) |
| do a map request completly outside both nodes | empty result set |
| remove the segment | segment removed successfull |
| try to get the way | way has gone |
| remove the first node | node removed |
| remove the second node | node removed |
| map request covering both old node locations | neither one of the nodes, the segment nor the way |
| try to get the first node | node has gone |
| get the history of the first node | two history entries, first creation, second deletion |
| please add more |
Suggestions on testcases: Add cases on adding name to node, segment and way and make sure it comes back correct. Names where UTF-8 needed, ie the greek alphabet.
*) In future server API's the map call (or any equivalent, if the map call is removed) will not return segments to nodes outside the requested area.

