[geocode-glib/wip/hadess/more-tests: 1/3] tests: Re-enable long-disabled "Bonneville" test




commit 2c11802f5e32f74f083f562c97b4b088fa98e4d6
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 30 14:52:01 2022 +0200

    tests: Re-enable long-disabled "Bonneville" test
    
    Adapt the test slightly for administrative level changes.

 geocode-glib/tests/geocode-glib.c    | 25 ++++++++++++++-----------
 geocode-glib/tests/locale_name2.json |  1 +
 geocode-glib/tests/meson.build       |  1 +
 3 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/geocode-glib/tests/geocode-glib.c b/geocode-glib/tests/geocode-glib.c
index b86fb0a..7cecd9d 100644
--- a/geocode-glib/tests/geocode-glib.c
+++ b/geocode-glib/tests/geocode-glib.c
@@ -695,6 +695,8 @@ test_locale_name (void)
        GeocodeLocation *loc;
        char *old_locale;
        g_autoptr (GHashTable) params = NULL;
+       GList *l;
+       gboolean found = FALSE;
 
        old_locale = g_strdup (setlocale(LC_MESSAGES, NULL));
 
@@ -731,16 +733,17 @@ test_locale_name (void)
        print_place (place);
 
        g_list_free_full (res, (GDestroyNotify) g_object_unref);
+       g_clear_pointer (&params, g_hash_table_destroy);
 
        /* Check Bonneville's region in French */
-        /* FIXME: Uncomment following and move variable declarations to top of
-         *        this function when this bug is resolved:
-         *        https://trac.openstreetmap.org/ticket/5111
-         */
-       /*GList *l;
-        gboolean found = FALSE;
        setlocale (LC_MESSAGES, "fr_FR.UTF-8");
-       object = geocode_forward_new_for_string ("bonneville");
+       /* The query parameters the mock server expects to receive. */
+       params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
+       add_attr_string (params, "q", "bonneville");
+       add_attr_string (params, "limit", "10");
+       add_attr_string (params, "bounded", "0");
+       object = create_forward_for_string ("bonneville", params,
+                                           "locale_name2.json");
        res = geocode_forward_search (object, &error);
        if (res == NULL) {
                g_warning ("Failed at geocoding: %s", error->message);
@@ -755,18 +758,18 @@ test_locale_name (void)
                loc = geocode_place_get_location (place);
                g_assert (loc != NULL);
 
-               if (g_strcmp0 (geocode_place_get_name (place), "Bonneville, Rhône-Alpes, France") == 0 &&
-                   g_strcmp0 (geocode_place_get_state (place), "Rhône-Alpes") == 0 &&
+               if (g_strcmp0 (geocode_place_get_name (place), "Bonneville, Haute-Savoie, 
Auvergne-Rhône-Alpes, France") == 0 &&
+                   g_strcmp0 (geocode_place_get_state (place), "Auvergne-Rhône-Alpes") == 0 &&
                    g_strcmp0 (geocode_place_get_country (place), "France") == 0 &&
                    g_strcmp0 (geocode_location_get_description (loc),
-                               "Bonneville, Rhône-Alpes, France") == 0) {
+                               "Bonneville, Haute-Savoie, Auvergne-Rhône-Alpes, France") == 0) {
                        found = TRUE;
                         break;
                 }
        }
 
        g_list_free_full (res, (GDestroyNotify) g_object_unref);
-       g_assert (found);*/
+       g_assert (found);
 
        /* And reset the locale */
        setlocale (LC_MESSAGES, old_locale);
diff --git a/geocode-glib/tests/locale_name2.json b/geocode-glib/tests/locale_name2.json
new file mode 100644
index 0000000..271e3f8
--- /dev/null
+++ b/geocode-glib/tests/locale_name2.json
@@ -0,0 +1 @@
+[{"place_id":282531357,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"relation","osm_id":1351402,"boundingbox":["50.059002","50.0960779","2.2311022","2.2943196"],"lat":"50.082567","lon":"2.2486687","display_name":"Bonneville,
 Amiens, Somme, Hauts-de-France, France métropolitaine, 80670, 
France","place_rank":16,"category":"boundary","type":"administrative","importance":0.6513383770901786,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_boundary_administrative.p.20.png","address":{"village":"Bonneville","municipality":"Amiens","county":"Somme","state":"Hauts-de-France","ISO3166-2-lvl4":"FR-HDF","region":"France
 
métropolitaine","postcode":"80670","country":"France","country_code":"fr"}},{"place_id":282390755,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"relation","osm_id":111341,"boundingbox":["45.8166572","45.8622904","-0.0739587","-0.0262735"],"lat":"45.83932675","lon":"-0.
 05154990942654531","display_name":"Bonneville, Val-d'Auge, Cognac, Charente, Nouvelle-Aquitaine, France 
métropolitaine, 16170, 
France","place_rank":18,"category":"boundary","type":"administrative","importance":0.6095585374247885,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_boundary_administrative.p.20.png","address":{"city_district":"Bonneville","city":"Val-d'Auge","municipality":"Cognac","county":"Charente","state":"Nouvelle-Aquitaine","ISO3166-2-lvl4":"FR-NAQ","region":"France
 
métropolitaine","postcode":"16170","country":"France","country_code":"fr"}},{"place_id":282563156,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"relation","osm_id":75366,"boundingbox":["46.0420063","46.1150528","6.3471949","6.460721"],"lat":"46.0775797","lon":"6.4086189","display_name":"Bonneville,
 Haute-Savoie, Auvergne-Rhône-Alpes, France métropolitaine, 74130, 
France","place_rank":16,"category":"boundary","type":"administrative","importan
 
ce":0.6029347079419282,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_boundary_administrative.p.20.png","address":{"town":"Bonneville","municipality":"Bonneville","county":"Haute-Savoie","ISO3166-2-lvl6":"FR-74","state":"Auvergne-Rhône-Alpes","ISO3166-2-lvl4":"FR-ARA","region":"France
 
métropolitaine","postcode":"74130","country":"France","country_code":"fr"}},{"place_id":282541683,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"relation","osm_id":1416617,"boundingbox":["43.0193832","43.626905","-112.519861","-111.043997"],"lat":"43.3993844","lon":"-111.4752257","display_name":"Bonneville
 County, Idaho, États-Unis 
d'Amérique","place_rank":12,"category":"boundary","type":"administrative","importance":0.5642206645715172,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_boundary_administrative.p.20.png","address":{"county":"Bonneville
 County","state":"Idaho","ISO3166-2-lvl4":"US-ID","country":"États-Unis d'Amér
 ique","country_code":"us"}},{"place_id":283023689,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"relation","osm_id":1668743,"boundingbox":["45.7228987","46.236958","6.2179214","7.0452884"],"lat":"45.979950900000006","lon":"6.775879244281295","display_name":"Bonneville,
 Haute-Savoie, Auvergne-Rhône-Alpes, France métropolitaine, 
France","place_rank":14,"category":"boundary","type":"administrative","importance":0.42005439055814375,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_boundary_administrative.p.20.png","address":{"municipality":"Bonneville","county":"Haute-Savoie","ISO3166-2-lvl6":"FR-74","state":"Auvergne-Rhône-Alpes","ISO3166-2-lvl4":"FR-ARA","region":"France
 métropolitaine","country":"France","country_code":"fr"}},{"place_id":15796519,"licence":"Data © 
OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"node","osm_id":1739928493,"boundingbox":["45.817921","45.857921","-0.0601889","-0.
 0201889"],"lat":"45.837921","lon":"-0.0401889","display_name":"Bonneville, Val-d'Auge, Cognac, Charente, 
Nouvelle-Aquitaine, France métropolitaine, 16170, 
France","place_rank":19,"category":"place","type":"village","importance":0.375,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_place_village.p.20.png","address":{"village":"Bonneville","city":"Val-d'Auge","municipality":"Cognac","county":"Charente","state":"Nouvelle-Aquitaine","ISO3166-2-lvl4":"FR-NAQ","region":"France
 
métropolitaine","postcode":"16170","country":"France","country_code":"fr"}},{"place_id":15214663,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"node","osm_id":1686342914,"boundingbox":["48.7163969","48.7563969","-1.5269388","-1.4869388"],"lat":"48.7363969","lon":"-1.5069388","display_name":"Bonneville,
 Champeaux, Avranches, Manche, Normandie, France métropolitaine, 50530, 
France","place_rank":20,"category":"place","type":"hamlet","importance":0.35,"icon
 
":"https://nominatim.openstreetmap.org/ui/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Bonneville","village":"Champeaux","municipality":"Avranches","county":"Manche","state":"Normandie","region":"France
 
métropolitaine","postcode":"50530","country":"France","country_code":"fr"}},{"place_id":46909914,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"node","osm_id":4028881623,"boundingbox":["45.7583226","45.7983226","3.5772885","3.6172885"],"lat":"45.7783226","lon":"3.5972885","display_name":"Bonneville,
 Vollore-Ville, Thiers, Puy-de-Dôme, Auvergne-Rhône-Alpes, France métropolitaine, 63120, 
France","place_rank":20,"category":"place","type":"hamlet","importance":0.35,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Bonneville","village":"Vollore-Ville","municipality":"Thiers","county":"Puy-de-Dôme","state":"Auvergne-Rhône-Alpes","ISO3166-2-lvl4":"FR-ARA","region":"Fra
 nce 
métropolitaine","postcode":"63120","country":"France","country_code":"fr"}},{"place_id":15125320,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"node","osm_id":1641963918,"boundingbox":["47.91306","47.95306","1.6593024","1.6993024"],"lat":"47.93306","lon":"1.6793024","display_name":"Bonneville,
 Coulmiers, Orléans, Loiret, Centre-Val de Loire, France métropolitaine, 45130, 
France","place_rank":20,"category":"place","type":"hamlet","importance":0.35,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Bonneville","village":"Coulmiers","municipality":"Orléans","county":"Loiret","state":"Centre-Val
 de Loire","region":"France 
métropolitaine","postcode":"45130","country":"France","country_code":"fr"}},{"place_id":17161824,"licence":"Data
 © OpenStreetMap contributors, ODbL 1.0. 
https://osm.org/copyright","osm_type":"node","osm_id":1938477229,"boundingbox":["46.0011172","46.0411172";
 ,"1.7783732","1.8183732"],"lat":"46.0211172","lon":"1.7983732","display_name":"Bonneville, Thauron, Guéret, 
Creuse, Nouvelle-Aquitaine, France métropolitaine, 23250, 
France","place_rank":20,"category":"place","type":"hamlet","importance":0.35,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Bonneville","village":"Thauron","municipality":"Guéret","county":"Creuse","state":"Nouvelle-Aquitaine","ISO3166-2-lvl4":"FR-NAQ","region":"France
 métropolitaine","postcode":"23250","country":"France","country_code":"fr"}}]
\ No newline at end of file
diff --git a/geocode-glib/tests/meson.build b/geocode-glib/tests/meson.build
index 51571b6..8e9963a 100644
--- a/geocode-glib/tests/meson.build
+++ b/geocode-glib/tests/meson.build
@@ -43,6 +43,7 @@ if get_option('enable-installed-tests')
   endforeach
   install_data('locale_format.json',
                'locale_name.json',
+               'locale_name2.json',
                'nominatim-area.json',
                'nominatim-data-type-change.json',
                'nominatim-no-results.json',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]