Fix the tests
This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
test/regression.diffs
|
||||
test/regression.out
|
||||
regression.diffs
|
||||
regression.out
|
||||
test/results
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
-- Install dependencies
|
||||
CREATE EXTENSION plpythonu;
|
||||
CREATE EXTENSION postgis;
|
||||
-- Install the extension
|
||||
CREATE EXTENSION crankshaft;
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
-- Install dependencies
|
||||
CREATE EXTENSION plpythonu;
|
||||
CREATE EXTENSION postgis;
|
||||
-- Install the extension
|
||||
CREATE EXTENSION crankshaft;
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
-- Install dependencies
|
||||
CREATE EXTENSION plpythonu;
|
||||
CREATE EXTENSION postgis;
|
||||
|
||||
-- Install the extension
|
||||
CREATE EXTENSION crankshaft;
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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...'
|
||||
|
||||
Reference in New Issue
Block a user