Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

releasing 0.5.4

  • Loading branch information...
commit 9bbb62f4a36698a42ab2da067a8b8deec2446788 1 parent 5209d4a
@lsbardel authored
View
2  .gitignore
@@ -1,5 +1,6 @@
*.pyc
*.egg
+*.so
dist/*
build/*
.settings/*
@@ -9,4 +10,3 @@ docs/build/*
.pydevproject
MANIFEST
vendor/src/hr.c
-stdnet/lib/hr.so
View
4 CHANGELOG.rst
@@ -1,5 +1,6 @@
Ver. 0.5.4 - Development
============================
+* Another bug fixing release with a couple of new functionalities and a new ``contrib`` application.
* Fixed a filtering problem when performing exclude on unique fields.
* Refactored registration utilities.
* Added :func:`stdnet.orm.test_unique` for testing uniqueness.
@@ -9,7 +10,8 @@ Ver. 0.5.4 - Development
* Added ``pre_save`` and ``post_save`` signals.
* Added ``pre_delete`` and ``post_delete`` signals.
* Bug fix on ``disptach`` module which was failing when using python 3.
-* **216 regression tests** with **73%** coverage.
+* Several more tests.
+* **218 regression tests** with **73%** coverage.
Ver. 0.5.3 - 2011 Apr 30
=============================
View
7 clean.py
@@ -25,9 +25,9 @@ def rmfiles(path, ext = None, rmcache = True):
if ext == None or sf[1] == ext:
tall += 1
trem += rmgeneric(fullpath, os.remove)
- elif f == '__pycache__' and rmcache:
- shutil.rmtree(fullpath)
- tall += 1
+ elif f == '__pycache__' and rmcache:
+ shutil.rmtree(fullpath)
+ tall += 1
elif os.path.isdir(fullpath):
r,ra = rmfiles(fullpath, ext)
trem += r
@@ -40,3 +40,4 @@ def rmfiles(path, ext = None, rmcache = True):
path = os.curdir
removed, allfiles = rmfiles(path,'pyc')
print('removed {0} pyc files out of {1}'.format(removed, allfiles))
+
View
2  docs/source/index.rst
@@ -14,7 +14,7 @@ Simple to use and configure.
It includes a modified version of redis-py_ compatible with ``python 3``. There are no dependencies
and the library requires ``python 2.6`` or above, including ``python 3``.
-There are over 180 tests with a coverage of about 70%.
+There are over 200 tests with a coverage of about 75%.
The library is stable and used in production.
View
40 setup.py
@@ -4,18 +4,23 @@
import os
import sys
-package_name = 'stdnet'
+package_name = 'stdnet'
package_fullname = 'python-%s' % package_name
-root_dir = os.path.split(os.path.abspath(__file__))[0]
-package_dir = os.path.join(root_dir, package_name)
+root_dir = os.path.split(os.path.abspath(__file__))[0]
+package_dir = os.path.join(root_dir, package_name)
+def get_module():
+ if root_dir not in sys.path:
+ sys.path.insert(0,root_dir)
+ return __import__(package_name)
+
+mod = get_module()
# Try to import lib build
try:
from vendor.setup import libparams
except ImportError:
libparams = {'cmdclass': {}}
-
# Switch this of for now
libparams = {'cmdclass': {}}
@@ -34,13 +39,6 @@ def finalize_options(self):
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']
-
-def get_module():
- if root_dir not in sys.path:
- sys.path.insert(0,root_dir)
- return __import__(package_name)
-
-mod = get_module()
def read(fname):
@@ -80,10 +78,11 @@ def get_rel_dir(d,base,res=''):
for dirpath, dirnames, filenames in os.walk(package_dir):
# Ignore dirnames that start with '.'
for i, dirname in enumerate(dirnames):
- if dirname.startswith('.'): del dirnames[i]
+ if dirname.startswith('.') or dirname == '__pycache__':
+ del dirnames[i]
if '__init__.py' in filenames:
packages.append('.'.join(fullsplit(dirpath)[len_root_dir:]))
- elif filenames:
+ elif filenames and not dirpath.endswith('__pycache__'):
rel_dir = get_rel_dir(dirpath,root_dir)
data_files.append([rel_dir, [os.path.join(dirpath, f) for f in filenames]])
@@ -91,7 +90,7 @@ def get_rel_dir(d,base,res=''):
for file_info in data_files:
file_info[0] = '\\PURELIB\\%s' % file_info[0]
-
+
libparams.update({
'name': package_fullname,
'version': mod.__version__,
@@ -103,18 +102,7 @@ def get_rel_dir(d,base,res=''):
'long_description': read('README.rst'),
'packages': packages,
'data_files': data_files,
- 'classifiers': [
- 'Development Status :: 4 - Beta',
- 'Environment :: Plugins',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: BSD License',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Topic :: Utilities',
- 'Topic :: Database'
- ]
+ 'classifiers': mod.CLASSIFIERS
})
setup(**libparams)
View
15 stdnet/__init__.py
@@ -9,9 +9,22 @@ def get_version():
__author__ = "Luca Sbardella"
__contact__ = "luca.sbardella@gmail.com"
__homepage__ = "https://github.com/lsbardel/python-stdnet"
+CLASSIFIERS = [
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Plugins',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3.1',
+ 'Programming Language :: Python :: 3.2',
+ 'Topic :: Utilities',
+ 'Topic :: Database'
+ ]
-sphinxtogithub = False
+sphinxtogithub = True
from .exceptions import *
from .backends import *
View
2  stdnet/lib/__init__.py
@@ -1,5 +1,5 @@
try:
- from stdlib import *
+ from .stdlib import *
hasextensions = True
except:
hasextensions = False
View
121 tests/regression/filter/instruments.py
@@ -0,0 +1,121 @@
+from stdnet.utils import populate, zip
+
+from examples.models import Instrument, Fund, Position
+from regression.finance import tests as fintests
+
+
+class TestFiler(fintests.BaseFinance):
+
+ def testAll(self):
+ qs = Instrument.objects.all()
+ self.assertTrue(qs.count() > 0)
+
+ def testFilterIn(self):
+ filter = Instrument.objects.filter
+ eur = dict(((o.id,o) for o in filter(ccy = 'EUR')))
+ usd = dict(((o.id,o) for o in filter(ccy = 'USD')))
+ all = set(eur).union(set(usd))
+ CCYS = ('EUR','USD')
+ qs = filter(ccy__in = CCYS)
+ us = set()
+ for inst in qs:
+ us.add(inst.id)
+ self.assertTrue(inst.ccy in CCYS)
+ zero = all - us
+ self.assertTrue(qs)
+ self.assertEqual(len(zero),0)
+
+ def testDoubleFilter(self):
+ qs = Instrument.objects.filter(ccy = 'EUR',type = 'future')
+ for inst in qs:
+ self.assertEqual(inst.ccy,'EUR')
+ self.assertEqual(inst.type,'future')
+
+ def testDoubleFilterIn(self):
+ CCYS = ('EUR','USD')
+ qs = Instrument.objects.filter(ccy__in = CCYS,type = 'future')
+ for inst in qs:
+ self.assertTrue(inst.ccy in CCYS)
+ self.assertEqual(inst.type,'future')
+
+ def testDoubleInFilter(self):
+ CCYS = ('EUR','USD','JPY')
+ types = ('equity','bond','future')
+ qs = Instrument.objects.filter(ccy__in = CCYS, type__in = types)
+ for inst in qs:
+ self.assertTrue(inst.ccy in CCYS)
+ self.assertTrue(inst.type in types)
+
+ def testSimpleExcludeFilter(self):
+ qs = Instrument.objects.exclude(ccy = 'JPY')
+ for inst in qs:
+ self.assertNotEqual(inst.ccy,'JPY')
+
+ def testExcludeFilterin(self):
+ CCYS = ('EUR','GBP','JPY')
+ A = Instrument.objects.filter(ccy__in = CCYS)
+ B = Instrument.objects.exclude(ccy__in = CCYS)
+ for inst in B:
+ self.assertTrue(inst.ccy not in CCYS)
+ all = dict(((o.id,o) for o in A))
+ all.update(dict(((o.id,o) for o in B)))
+ self.assertTrue(len(all),Instrument.objects.all().count())
+
+ def testDoubleExclude(self):
+ CCYS = ('EUR','GBP','JPY')
+ types = ('equity','bond','future')
+ A = Instrument.objects.exclude(ccy__in = CCYS, type__in = types)
+ for inst in A:
+ self.assertTrue(inst.ccy not in CCYS)
+ self.assertTrue(inst.type not in types)
+ self.assertTrue(len(A))
+
+ def testExcludeAndFilter(self):
+ CCYS = ('EUR','GBP')
+ types = ('equity','bond','future')
+ qs = Instrument.objects.exclude(ccy__in = CCYS).filter(type__in = types)
+ for inst in qs:
+ self.assertTrue(inst.ccy not in CCYS)
+ self.assertTrue(inst.type in types)
+ self.assertTrue(qs)
+
+ def testFilterIds(self):
+ ids = set((1,5,10))
+ qs = Instrument.objects.filter(id__in = ids)
+ self.assertEqual(len(qs),3)
+ cids = set((o.id for o in qs))
+ self.assertEqual(cids,ids)
+
+ def testFilterIdExclude(self):
+ CCYS = ('EUR','GBP')
+ types = ('equity','bond','future')
+ qt1 = set(Instrument.objects.filter(type__in = types))
+ qt = set((i.id for i in qt1))
+ qt2 = set(Instrument.objects.filter(id__in = qt))
+ self.assertEqual(qt1,qt2)
+ #
+ qt3 = set(Instrument.objects.exclude(id__in = qt))
+ qt4 = qt2.intersection(qt3)
+ self.assertFalse(qt4)
+ qs1 = set(Instrument.objects.filter(ccy__in = CCYS).exclude(type__in = types))
+ qs2 = set(Instrument.objects.filter(ccy__in = CCYS).exclude(id__in = qt))
+ self.assertEqual(qs1,qs2)
+
+ def testChangeFilter(self):
+ '''Change the value of a filter field and perform filtering to
+ check for zero values'''
+ insts = Instrument.objects.filter(ccy = 'EUR')
+ for inst in insts:
+ inst.ccy = 'USD'
+ inst.save()
+ insts = Instrument.objects.filter(ccy = 'EUR')
+ self.assertEqual(insts.count(),0)
+
+ def testFilterWithSpace(self):
+ insts = Instrument.objects.filter(type = 'bond option')
+ for inst in insts:
+ self.assertEqual(inst.type,'bond option')
+ self.assertTrue(inst)
+
+
+
View
119 tests/regression/filter/tests.py 100755 → 100644
@@ -1,117 +1,2 @@
-from examples.models import Instrument, Fund, Position
-from regression.finance import tests as fintests
-
-
-class TestFiler(fintests.BaseFinance):
-
- def testAll(self):
- qs = Instrument.objects.all()
- self.assertTrue(qs.count() > 0)
-
- def testFilterIn(self):
- filter = Instrument.objects.filter
- eur = dict(((o.id,o) for o in filter(ccy = 'EUR')))
- usd = dict(((o.id,o) for o in filter(ccy = 'USD')))
- all = set(eur).union(set(usd))
- CCYS = ('EUR','USD')
- qs = filter(ccy__in = CCYS)
- us = set()
- for inst in qs:
- us.add(inst.id)
- self.assertTrue(inst.ccy in CCYS)
- zero = all - us
- self.assertTrue(qs)
- self.assertEqual(len(zero),0)
-
- def testDoubleFilter(self):
- qs = Instrument.objects.filter(ccy = 'EUR',type = 'future')
- for inst in qs:
- self.assertEqual(inst.ccy,'EUR')
- self.assertEqual(inst.type,'future')
-
- def testDoubleFilterIn(self):
- CCYS = ('EUR','USD')
- qs = Instrument.objects.filter(ccy__in = CCYS,type = 'future')
- for inst in qs:
- self.assertTrue(inst.ccy in CCYS)
- self.assertEqual(inst.type,'future')
-
- def testDoubleInFilter(self):
- CCYS = ('EUR','USD','JPY')
- types = ('equity','bond','future')
- qs = Instrument.objects.filter(ccy__in = CCYS, type__in = types)
- for inst in qs:
- self.assertTrue(inst.ccy in CCYS)
- self.assertTrue(inst.type in types)
-
- def testSimpleExcludeFilter(self):
- qs = Instrument.objects.exclude(ccy = 'JPY')
- for inst in qs:
- self.assertNotEqual(inst.ccy,'JPY')
-
- def testExcludeFilterin(self):
- CCYS = ('EUR','GBP','JPY')
- A = Instrument.objects.filter(ccy__in = CCYS)
- B = Instrument.objects.exclude(ccy__in = CCYS)
- for inst in B:
- self.assertTrue(inst.ccy not in CCYS)
- all = dict(((o.id,o) for o in A))
- all.update(dict(((o.id,o) for o in B)))
- self.assertTrue(len(all),Instrument.objects.all().count())
-
- def testDoubleExclude(self):
- CCYS = ('EUR','GBP','JPY')
- types = ('equity','bond','future')
- A = Instrument.objects.exclude(ccy__in = CCYS, type__in = types)
- for inst in A:
- self.assertTrue(inst.ccy not in CCYS)
- self.assertTrue(inst.type not in types)
- self.assertTrue(len(A))
-
- def testExcludeAndFilter(self):
- CCYS = ('EUR','GBP')
- types = ('equity','bond','future')
- qs = Instrument.objects.exclude(ccy__in = CCYS).filter(type__in = types)
- for inst in qs:
- self.assertTrue(inst.ccy not in CCYS)
- self.assertTrue(inst.type in types)
- self.assertTrue(qs)
-
- def testFilterIds(self):
- ids = set((1,5,10))
- qs = Instrument.objects.filter(id__in = ids)
- self.assertEqual(len(qs),3)
- cids = set((o.id for o in qs))
- self.assertEqual(cids,ids)
-
- def testFilterUniqueExclude(self):
- CCYS = ('EUR','GBP')
- types = ('equity','bond','future')
- qt1 = set(Instrument.objects.filter(type__in = types))
- qt = set((i.id for i in qt1))
- qt2 = set(Instrument.objects.filter(id__in = qt))
- self.assertEqual(qt1,qt2)
- #
- qt3 = set(Instrument.objects.exclude(id__in = qt))
- qt4 = qt2.intersection(qt3)
- self.assertFalse(qt4)
- qs1 = set(Instrument.objects.filter(ccy__in = CCYS).exclude(type__in = types))
- qs2 = set(Instrument.objects.filter(ccy__in = CCYS).exclude(id__in = qt))
- self.assertEqual(qs1,qs2)
-
- def testChangeFilter(self):
- '''Change the value of a filter field and perform filtering to
- check for zero values'''
- insts = Instrument.objects.filter(ccy = 'EUR')
- for inst in insts:
- inst.ccy = 'USD'
- inst.save()
- insts = Instrument.objects.filter(ccy = 'EUR')
- self.assertEqual(insts.count(),0)
-
- def testFilterWithSpace(self):
- insts = Instrument.objects.filter(type = 'bond option')
- for inst in insts:
- self.assertEqual(inst.type,'bond option')
- self.assertTrue(inst)
-
+from .uniquefield import *
+from .instruments import *
View
39 tests/regression/filter/uniquefield.py
@@ -0,0 +1,39 @@
+from random import randint
+
+from stdnet import test
+from stdnet.utils import populate, zip, range
+
+from examples.models import SimpleModel
+
+
+SIZE = 200
+sports = ['football','rugby','swimming','running','cycling']
+
+codes = set(populate('string',SIZE, min_len = 5, max_len = 20))
+SIZE = len(codes)
+groups = populate('choice',SIZE,choice_from=sports)
+codes = list(codes)
+
+class TestUniqueFilter(test.TestCase):
+
+ def setUp(self):
+ self.orm.register(SimpleModel)
+ for n,g in zip(codes,groups):
+ SimpleModel(code = n, group = g).save(commit = False)
+ SimpleModel.commit()
+
+ def testFilterSimple(self):
+ for i in range(10):
+ i = randint(0,len(codes)-1)
+ code = codes[i]
+ r = SimpleModel.objects.filter(code = code)
+ self.assertEqual(r.count(),1)
+ self.assertEqual(r[0].code,code)
+
+ def testExcludeSimple(self):
+ for i in range(10):
+ i = randint(0,len(codes)-1)
+ code = codes[i]
+ r = SimpleModel.objects.exclude(code = code)
+ self.assertEqual(r.count(),SIZE-1)
+ self.assertFalse(code in set((o.code for o in r)))
Please sign in to comment.
Something went wrong with that request. Please try again.