Removed folder-based versioning for extension files
This commit is contained in:
20
geocoder/extension/test/expected/00_install_test.out
Normal file
20
geocoder/extension/test/expected/00_install_test.out
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Install dependencies
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION plpythonu;
|
||||
CREATE EXTENSION cartodb;
|
||||
-- Mock the quota check
|
||||
SELECT cartodb.CDB_SetUserQuotaInBytes(0);
|
||||
cdb_setuserquotainbytes
|
||||
-------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- Install the extension
|
||||
CREATE EXTENSION cdb_geocoder;
|
||||
-- Mock the varnish invalidation function
|
||||
CREATE OR REPLACE FUNCTION public.cdb_invalidate_varnish(table_name text) RETURNS void AS $$
|
||||
BEGIN
|
||||
RETURN;
|
||||
END
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
27
geocoder/extension/test/expected/20_admin0_test.out
Normal file
27
geocoder/extension/test/expected/20_admin0_test.out
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Check that the synonym function is callable, should return NULL
|
||||
SELECT (admin0_synonym_lookup(Array['United States', 'ESP'])).*;
|
||||
q | adm0_a3
|
||||
---------------+---------
|
||||
United States |
|
||||
ESP |
|
||||
(2 rows)
|
||||
|
||||
-- Check that the geocoding function is callable, should return success = false
|
||||
SELECT (geocode_admin0_polygons(Array['Spain', 'USA', ''])).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
Spain | | f
|
||||
USA | | f
|
||||
| | f
|
||||
(3 rows)
|
||||
|
||||
-- Add a few synonyms
|
||||
COPY admin0_synonyms (name, rank, created_at, updated_at, the_geom, the_geom_webmercator, cartodb_id, adm0_a3, name_) FROM stdin;
|
||||
-- Check that the synonym function is callable, should return their iso codes
|
||||
SELECT (admin0_synonym_lookup(Array['United States', 'ESP'])).*;
|
||||
q | adm0_a3
|
||||
---------------+---------
|
||||
United States | USA
|
||||
ESP | ESP
|
||||
(2 rows)
|
||||
|
||||
43
geocoder/extension/test/expected/30_admin1_test.out
Normal file
43
geocoder/extension/test/expected/30_admin1_test.out
Normal file
@@ -0,0 +1,43 @@
|
||||
-- Check that the geocoding functions are callable, should return NULL
|
||||
SELECT (geocode_admin1_polygons(Array['TX','Cuidad Real', 'sevilla'])).*;
|
||||
q | geom | success
|
||||
-------------+------+---------
|
||||
TX | | f
|
||||
Cuidad Real | | f
|
||||
sevilla | | f
|
||||
(3 rows)
|
||||
|
||||
SELECT (geocode_admin1_polygons(Array['NH', 'Vermont'], 'United States')).*;
|
||||
q | geom | success
|
||||
---------+------+---------
|
||||
NH | | f
|
||||
Vermont | | f
|
||||
(2 rows)
|
||||
|
||||
SELECT (geocode_admin1_polygons(Array['az', 'az'], Array['Ecuador', 'USA'])).*;
|
||||
q | c | geom | success
|
||||
----+---------+------+---------
|
||||
az | Ecuador | | f
|
||||
az | USA | | f
|
||||
(2 rows)
|
||||
|
||||
-- Add a few data to the sources
|
||||
INSERT INTO global_province_polygons (the_geom, synonyms, iso3) VALUES (
|
||||
'0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040',
|
||||
Array['vipava','obcina vipava','vipava, obcina'],
|
||||
'SVN'
|
||||
);
|
||||
-- Check that the synonym function is callable, should return true
|
||||
SELECT (geocode_admin1_polygons(Array['obcina vipava'])).success;
|
||||
success
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- Check that it returns the mocked geometry above
|
||||
SELECT (geocode_admin1_polygons(Array['obcina vipava'])).geom;
|
||||
geom
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040
|
||||
(1 row)
|
||||
|
||||
16
geocoder/extension/test/expected/40_ipaddr_test.out
Normal file
16
geocoder/extension/test/expected/40_ipaddr_test.out
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Check that the geocoding function is callable, should return success = false
|
||||
SELECT (geocode_ip(Array['100.0.24.0'])).*;
|
||||
q | geom | success
|
||||
------------+------+---------
|
||||
100.0.24.0 | | f
|
||||
(1 row)
|
||||
|
||||
-- Add a few IP sources
|
||||
COPY ip_address_locations (network_start_ip, the_geom, cartodb_id, created_at, updated_at, the_geom_webmercator) FROM stdin;
|
||||
-- Check that the geocoding function is callable, should return success = true
|
||||
SELECT (geocode_ip(Array['2.235.35.0'])).*;
|
||||
q | geom | success
|
||||
------------+----------------------------------------------------+---------
|
||||
2.235.35.0 | 0101000020E610000072F90FE9B7CF22405DFE43FAEDC34640 | t
|
||||
(1 row)
|
||||
|
||||
70
geocoder/extension/test/expected/50_namedplaces_test.out
Normal file
70
geocoder/extension/test/expected/50_namedplaces_test.out
Normal file
@@ -0,0 +1,70 @@
|
||||
-- Check that the different geocoding functions are callable, should return success = false
|
||||
SELECT (geocode_namedplace(Array['Madrid', 'New York City', 'sunapee'])).*;
|
||||
q | geom | success
|
||||
---------------+------+---------
|
||||
Madrid | | f
|
||||
New York City | | f
|
||||
sunapee | | f
|
||||
(3 rows)
|
||||
|
||||
SELECT (geocode_namedplace(Array['Elche', 'Granada', 'Madrid'], 'Spain')).*;
|
||||
q | c | geom | success
|
||||
---------+-------+------+---------
|
||||
Elche | Spain | | f
|
||||
Granada | Spain | | f
|
||||
Madrid | Spain | | f
|
||||
(3 rows)
|
||||
|
||||
SELECT (geocode_namedplace(Array['sunapee', 'sunapeeee', 'New York City', 'Madrid'], Array['', 'US', 'United States', NULL])).*;
|
||||
q | c | geom | success
|
||||
---------------+---------------+------+---------
|
||||
Madrid | | | f
|
||||
sunapee | | | f
|
||||
sunapeeee | US | | f
|
||||
New York City | United States | | f
|
||||
(4 rows)
|
||||
|
||||
SELECT (geocode_namedplace(Array['Portland', 'Portland', 'New York City'], Array['Maine', 'Oregon', NULL], 'USA')).*;
|
||||
q | a1 | c | geom | success
|
||||
---------------+--------+-----+------+---------
|
||||
New York City | | USA | | f
|
||||
Portland | Maine | USA | | f
|
||||
Portland | Oregon | USA | | f
|
||||
(3 rows)
|
||||
|
||||
SELECT (geocode_namedplace(Array['Portland'], 'Oregon', 'USA')).*;
|
||||
q | a1 | c | geom | success
|
||||
----------+--------+-----+------+---------
|
||||
Portland | Oregon | USA | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_namedplace(Array['Portland', 'Portland', 'New York City'], Array['Maine', 'Oregon', NULL], Array['USA'])).*;
|
||||
q | a1 | c | geom | success
|
||||
---------------+--------+-----+------+---------
|
||||
New York City | | USA | | f
|
||||
Portland | Maine | USA | | f
|
||||
Portland | Oregon | USA | | f
|
||||
(3 rows)
|
||||
|
||||
SELECT namedplace_guess_country(Array['granada', 'jaen', 'cordoba', 'madrid', 'valladolid']);
|
||||
namedplace_guess_country
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- Add a named place source
|
||||
COPY global_cities_alternates_limited (geoname_id, name, the_geom, created_at, updated_at, the_geom_webmercator, preferred, lowername, cartodb_id, admin1_geonameid, iso2, admin1) FROM stdin;
|
||||
COPY global_cities_points_limited (geoname_id, name, asciiname, altnames, featclass, featcode, iso2, admin1, admin2, population, the_geom, created_at, updated_at, the_geom_webmercator, cartodb_id, lowername) FROM stdin;
|
||||
-- Check that the geocoding function is callable, should return success = true
|
||||
SELECT (geocode_namedplace(Array['Barcelona'])).*;
|
||||
q | geom | success
|
||||
-----------+----------------------------------------------------+---------
|
||||
Barcelona | 0101000020E6100000CA15DEE522E653C0A4C2D842902B4540 | t
|
||||
(1 row)
|
||||
|
||||
SELECT namedplace_guess_country(Array['Barcelona']);
|
||||
namedplace_guess_country
|
||||
--------------------------
|
||||
ES
|
||||
(1 row)
|
||||
|
||||
96
geocoder/extension/test/expected/60_postalcode_test.out
Normal file
96
geocoder/extension/test/expected/60_postalcode_test.out
Normal file
@@ -0,0 +1,96 @@
|
||||
SELECT (geocode_postalcode_polygons(Array['03204'], Array['Spain'])).*;
|
||||
q | c | geom | success
|
||||
-------+-------+------+---------
|
||||
03204 | Spain | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_polygons(Array['03204'], 'ESP')).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
03204 | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_polygons(Array['03204'])).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
03204 | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_points(Array['03204'], 'Spain')).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
03204 | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_points('{03204}', 'Spain')).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
03204 | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_points(Array['03204'])).*;
|
||||
q | geom | success
|
||||
-------+------+---------
|
||||
03204 | | f
|
||||
(1 row)
|
||||
|
||||
SELECT (geocode_postalcode_points(Array['03204'], Array['Spain'])).*;
|
||||
q | c | iso3 | geom | success
|
||||
-------+-------+------+------+---------
|
||||
03204 | Spain | | | f
|
||||
(1 row)
|
||||
|
||||
SELECT geocode_greatbritain_outward('YO1 721');
|
||||
geocode_greatbritain_outward
|
||||
------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT (admin0_available_services(Array['Spain'])).*;
|
||||
q | adm0_a3 | postal_code_points | postal_code_polygons
|
||||
-------+---------+--------------------+----------------------
|
||||
Spain | | |
|
||||
(1 row)
|
||||
|
||||
-- Insert mock source data
|
||||
INSERT INTO global_postal_code_points (the_geom, iso3, postal_code, postal_code_num) VALUES (
|
||||
'0101000020E61000000000000000E040408036B47414764840',
|
||||
'ESP',
|
||||
'03204',
|
||||
3204
|
||||
);
|
||||
INSERT INTO global_postal_code_polygons (the_geom, iso3, postal_code, postal_code_num) VALUES (
|
||||
'0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040',
|
||||
'ESP',
|
||||
'03204',
|
||||
3204
|
||||
);
|
||||
INSERT INTO country_decoder (iso3, synonyms) VALUES (
|
||||
'ESP',
|
||||
Array['spain', 'Spain', 'ESP']
|
||||
);
|
||||
INSERT INTO available_services (adm0_a3, admin0, postal_code_points, postal_code_polygons) VALUES (
|
||||
'ESP',
|
||||
't',
|
||||
't',
|
||||
't'
|
||||
);
|
||||
INSERT INTO admin0_synonyms (adm0_a3, name, name_, rank) VALUES (
|
||||
'ESP',
|
||||
'Spain',
|
||||
'spain',
|
||||
3
|
||||
);
|
||||
INSERT INTO admin0_synonyms (adm0_a3, name, name_, rank) VALUES (
|
||||
'ESP',
|
||||
'ESP',
|
||||
'esp',
|
||||
4
|
||||
);
|
||||
-- Check that the geocoding function is callable, should return success = true
|
||||
SELECT (geocode_postalcode_polygons(Array['03204'], Array['Spain'])).geom;
|
||||
geom
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040
|
||||
(1 row)
|
||||
|
||||
Reference in New Issue
Block a user