Commit a573ce91 authored by lyricnz's avatar lyricnz
Browse files

Make more explicit messages when calling geonames services. Errors seem to

be normal for the backend right now.
parent 2b5c425d
......@@ -25,8 +25,7 @@ class GeoNamesAllTestCase extends DrupalWebTestCase {
parent::setUp('geonames');
variable_set('geonames_commercial_active', FALSE);
variable_set('geonames_cache', FALSE);
// Use the free server that doesn't require a username
variable_set('geonames_server', 'http://ws.geonames.org');
variable_set('geonames_username', 'demo');
}
/**
......@@ -36,7 +35,19 @@ class GeoNamesAllTestCase extends DrupalWebTestCase {
*/
function geonames_query($service, $query = array(), $options = NULL) {
unset($this->services[$service]);
return geonames_query($service, $query, $options);
$result = geonames_query($service, $query, $options);
if ($result == FALSE) {
$message = 'FALSE';
}
elseif (isset($result->status)) {
$message = t('Status: @message (@value)', array('@message' => $result->status['message'], '@value' => $result->status['value']));
}
else {
$message = 'OK';
}
$this->assertTrue($message == 'OK', t('Geonames query to service %service completed: !message', array('%service' => $service, '!message' => $message)));
return $result;
}
......@@ -105,7 +116,7 @@ class GeoNamesAllTestCase extends DrupalWebTestCase {
$this->assertEqual($results->total_results_count, 1, 'Found 1 result from "extendedFindNearby" A');
$result = $results->results[0];
$this->assertEqual($result['street'], 'Roble Ave', t('Found "Roble Ave" from "extendedFindNearby" A'));
$this->assertEqual($result['streetnumber'], '671', t('Found "61" from "extendedFindNearby" A'));
$this->assertEqual($result['streetnumber'], '671', t('Found "671" from "extendedFindNearby" A'));
// Test the "extendedFindNearby" service : other countries
$query = array('lat' => 47.3, 'lng' => 9);
......@@ -144,7 +155,7 @@ class GeoNamesAllTestCase extends DrupalWebTestCase {
$this->assertEqual($results->total_results_count, 1, 'Found 1 result from "findNearestAddress"');
$result = $results->results[0];
$this->assertEqual($result['street'], 'Roble Ave', t('Found "Roble Ave" from "findNearestAddress"'));
$this->assertEqual($result['streetnumber'], '671', t('Found "61" from "findNearestAddress"'));
$this->assertEqual($result['streetnumber'], '671', t('Found "671" from "findNearestAddress"'));
// Test the "findNearestIntersection" service
$query = array('lat' => 37.451, 'lng' => -122.18);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment