Refactor and new tests

This commit is contained in:
Javier Goizueta
2016-02-18 11:28:26 +01:00
parent 89cda152bd
commit e1951e1ea9
19 changed files with 262 additions and 78 deletions

View File

@@ -1,2 +1,2 @@
import poc
import random_seeds
import clustering

View File

@@ -1 +0,0 @@
from xyz import *

View File

@@ -1,6 +0,0 @@
import plpy
def xyz():
plpy.notice('XYZ...')
r = plpy.execute("select * from pg_class where relname='pg_class'")
return r[0]['reltype']

View File

@@ -0,0 +1,10 @@
import random
import numpy
def set_random_seeds(value):
"""
Set the seeds of the RNGs (Random Number Generators)
used internally.
"""
random.seed(value)
numpy.random.seed(value)

View File

@@ -22,7 +22,7 @@ setup(
license='MIT',
classifiers=[
'Development Status :: 1 - Planning',
'Development Status :: 3 - Alpha',
'Intended Audience :: Mapping comunity',
'Topic :: Maps :: Mapping Tools',
'License :: OSI Approved :: MIT License',
@@ -38,6 +38,8 @@ setup(
'test': ['unittest', 'nose', 'mock'],
},
# The choice of component versions is dictated by what's
# provisioned in the production servers.
install_requires=['pysal==1.11.0','numpy==1.6.1'],
requires=['pysal', 'numpy'],

View File

@@ -1,23 +0,0 @@
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import unittest
# from mock_plpy import MockPlPy
# plpy = MockPlPy()
#
# import sys
# sys.modules['plpy'] = plpy
from helper import plpy
import crankshaft
class TestPoc(unittest.TestCase):
def setUp(self):
plpy._reset()
def test_should_have_xyz(self):
plpy._define_result('select.*from\s+pg_class', [{'reltype': 111}])
assert crankshaft.poc.xyz() == 111
assert plpy.notices[0] == 'XYZ...'