dataservices-api/test
Juan Ignacio Sánchez Lara b0c1948c14 TL;DR: safer deployment and minor fixes
- Instead of modifying cdb_service_quota_info to return max_batch_size,
a new type (service_quota_info_batch) and a new function
(cdb_service_quota_info_batch) are created. That makes deployment safe.
- Fixes geocoding with forced batch size 1.
- Improves namespacing for count_estimate (->
cdb_dataservices_client.cdb_count_estimate).
- Improves namespacing for jsonb_array_casttext (->
cdb_dataservices_client.cdb_jsonb_array_casttext).
2018-07-18 14:57:40 +02:00
..
fixtures Fixed geocode street point integration tests 2016-01-25 18:48:27 +01:00
helpers Reduce precision on fixture points 2018-07-04 13:24:11 +02:00
integration TL;DR: safer deployment and minor fixes 2018-07-18 14:57:40 +02:00
__init__.py Created helper to be used in all the tests 2015-12-06 13:10:54 +01:00
README.md Update README.md 2016-11-07 12:14:05 +01:00
requirements.txt Integration tests dependencies 2018-06-26 11:07:38 +02:00
run_tests.py Fixed env variables cleaning 2018-06-26 10:56:14 +02:00

Geocoder API integration tests

This are the automatic integration tests for geocoder api (both client and server)

Usage

In order to execute the tests you have to execute the run_tests.py python script:

python run_tests.py [--host=cartodb.com --schema=https] username api_key

You can define the host where is going to execute the SQL API queries to test the geocoder API. By default the value is cartodb.com but you can put the host you need.

Tests

This suite of tests test the following parts of the geocoding API through the SQL API:

  • Admin 0 functions
  • Admin 1 functions
  • Named places functions
  • Postal code functions
  • Ip address functions
  • Street address functions (This will call Heremaps or Google so it will cost you 2 credits)
  • Routing functions
  • Isolines functions
  • Data Observatory functions

How to debug the tests

You won't be able to plug a debugger when using the run_test.py because of the usage of a subprocess and the piping.

You should be aware that some tests require some extra setup (a test table), that you'll need to do on your own in some cases (check the ImportHelper.import_test_dataset)

In order to do so, you need to use plain nosetests which comes prepared to that.

First, add this to the python test code:

from nose.tools import set_trace; set_trace()

Secondly, execute just your test with this:

GEOCODER_API_TEST_USERNAME=your_username \
GEOCODER_API_TEST_API_KEY=your_api_key \
GEOCODER_API_TEST_TABLE_NAME=your_test_table \
GEOCODER_API_TEST_HOST=your_target_test_host \
nosetests --where=integration/ test_data_observatory_functions.py:TestDataObservatoryFunctions.test_if_obs_search_is_ok

(replace the environment variables, test file, class and function according to your needs)

TODO: we need to refactor the test code a little to avoid these hindrances