From 3ded7da1d8ed5bc45f4a95873956257433303310 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Wed, 17 Feb 2016 11:46:29 +0100 Subject: [PATCH] Fix the tests --- CONTRIBUTING.md | 17 +++++++++++++++++ pg/.gitignore | 4 ++-- pg/sql/0.0.1/moran.sql | 4 ++-- pg/test/0.0.1/expected/01_install_test.out | 1 + pg/test/0.0.1/expected/02_poc_xyz_test.out | 4 +++- pg/test/0.0.1/results/01_install_test.out | 1 + pg/test/0.0.1/results/02_poc_xyz_test.out | 4 +++- pg/test/0.0.1/sql/01_install_test.sql | 1 + python/crankshaft/crankshaft/poc/xyz.py | 4 ++-- python/crankshaft/test/test_poc.py | 2 +- 10 files changed, 33 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 633199b..8b05872 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,3 +59,20 @@ the extension) with `_cdb_`. # Python ... + +## Testing + +Running the Python tests: + +``` +nosetests python/crankdown/test +``` + +Installing the Python package and running the PostgreSQL tests: + +``` +sudo pip install python/crankdown --upgrade +cd pg +sudo make install +make installcheck +``` diff --git a/pg/.gitignore b/pg/.gitignore index 8392e95..5d5e769 100644 --- a/pg/.gitignore +++ b/pg/.gitignore @@ -1,3 +1,3 @@ -test/regression.diffs -test/regression.out +regression.diffs +regression.out test/results diff --git a/pg/sql/0.0.1/moran.sql b/pg/sql/0.0.1/moran.sql index e70dad1..e93d972 100644 --- a/pg/sql/0.0.1/moran.sql +++ b/pg/sql/0.0.1/moran.sql @@ -17,6 +17,6 @@ RETURNS TABLE ( ) AS $$ from crankshaft.clustering import moran_local - -- TODO: use named parameters or a dictionary + # TODO: use named parameters or a dictionary return moran_local(t, attr, significance, num_ngbrs, permutations, geom_column, id_col, w_type) -$$ LANGUAGE plpython2u; +$$ LANGUAGE plpythonu; diff --git a/pg/test/0.0.1/expected/01_install_test.out b/pg/test/0.0.1/expected/01_install_test.out index 26bd1bf..8e1f9fc 100644 --- a/pg/test/0.0.1/expected/01_install_test.out +++ b/pg/test/0.0.1/expected/01_install_test.out @@ -1,4 +1,5 @@ -- Install dependencies CREATE EXTENSION plpythonu; +CREATE EXTENSION postgis; -- Install the extension CREATE EXTENSION crankshaft; diff --git a/pg/test/0.0.1/expected/02_poc_xyz_test.out b/pg/test/0.0.1/expected/02_poc_xyz_test.out index bb23ea2..2af7619 100644 --- a/pg/test/0.0.1/expected/02_poc_xyz_test.out +++ b/pg/test/0.0.1/expected/02_poc_xyz_test.out @@ -1,6 +1,8 @@ SELECT cdb_crankshaft.cdb_poc_xyz(); +NOTICE: XYZ... +CONTEXT: PL/Python function "cdb_poc_xyz" cdb_poc_xyz ------------- - xyz-result + 83 (1 row) diff --git a/pg/test/0.0.1/results/01_install_test.out b/pg/test/0.0.1/results/01_install_test.out index 26bd1bf..8e1f9fc 100644 --- a/pg/test/0.0.1/results/01_install_test.out +++ b/pg/test/0.0.1/results/01_install_test.out @@ -1,4 +1,5 @@ -- Install dependencies CREATE EXTENSION plpythonu; +CREATE EXTENSION postgis; -- Install the extension CREATE EXTENSION crankshaft; diff --git a/pg/test/0.0.1/results/02_poc_xyz_test.out b/pg/test/0.0.1/results/02_poc_xyz_test.out index bb23ea2..2af7619 100644 --- a/pg/test/0.0.1/results/02_poc_xyz_test.out +++ b/pg/test/0.0.1/results/02_poc_xyz_test.out @@ -1,6 +1,8 @@ SELECT cdb_crankshaft.cdb_poc_xyz(); +NOTICE: XYZ... +CONTEXT: PL/Python function "cdb_poc_xyz" cdb_poc_xyz ------------- - xyz-result + 83 (1 row) diff --git a/pg/test/0.0.1/sql/01_install_test.sql b/pg/test/0.0.1/sql/01_install_test.sql index 11e8d14..4edd186 100644 --- a/pg/test/0.0.1/sql/01_install_test.sql +++ b/pg/test/0.0.1/sql/01_install_test.sql @@ -1,5 +1,6 @@ -- Install dependencies CREATE EXTENSION plpythonu; +CREATE EXTENSION postgis; -- Install the extension CREATE EXTENSION crankshaft; diff --git a/python/crankshaft/crankshaft/poc/xyz.py b/python/crankshaft/crankshaft/poc/xyz.py index 558c77c..197f9db 100644 --- a/python/crankshaft/crankshaft/poc/xyz.py +++ b/python/crankshaft/crankshaft/poc/xyz.py @@ -2,5 +2,5 @@ import plpy def xyz(): plpy.notice('XYZ...') - r = plpy.execute("SELECT * FROM table") - return r[0]['x'] + r = plpy.execute("select * from pg_class where relname='pg_class'") + return r[0]['reltype'] diff --git a/python/crankshaft/test/test_poc.py b/python/crankshaft/test/test_poc.py index ca90735..06f08a3 100644 --- a/python/crankshaft/test/test_poc.py +++ b/python/crankshaft/test/test_poc.py @@ -18,6 +18,6 @@ class TestPoc(unittest.TestCase): plpy._reset() def test_should_have_xyz(self): - plpy._define_result('select\s+\*\s+from\s+table', [{'x': 111}]) + plpy._define_result('select.*from\s+pg_class', [{'reltype': 111}]) assert crankshaft.poc.xyz() == 111 assert plpy.notices[0] == 'XYZ...'