Skip to content

Commit 0862d13

Browse files
author
quantmind
committed
fixed csv serializer, increased coverage, nose testing
1 parent e8e04fb commit 0862d13

File tree

27 files changed

+274
-166
lines changed

27 files changed

+274
-166
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
*.egg
33
*.so
44
*.prof
5-
dist/*
5+
dist
66
lib/src/hr.c
77
stdnet/lib/hr.pyd
88
stdnet/lib/hr.so
99
build/*
10-
.settings/*
11-
docs/build/*
10+
.settings
11+
docs/build
1212
.coverage
13-
htmlcov/*
13+
htmlcov
1414
.project
1515
.pydevproject
1616
MANIFEST

CHANGELOG.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Ver. 0.7.0 - Development
44
===============================
5-
* **It requires redis_ 2.6 or higher**.
5+
* **It requires redis 2.6 or higher**.
66
* Some backward incompatible changes in the API and database schema.
77
* Tons of new features including a richer query API, improved performance via custom
88
query options, more flexible transactions, lua_ scripting for redis_ and
@@ -44,7 +44,8 @@ Ver. 0.7.0 - Development
4444
using python 2.6.
4545
* Moved the contrib module to :mod:`stdnet.apps`.
4646
* Added :mod:`stdnet.utils.dates`.
47-
* **568 regression tests** with **90%** coverage.
47+
* Added :mod:`stdnet.utils.path`.
48+
* **570 regression tests** with **91%** coverage.
4849

4950
.. _vers06:
5051

README.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,33 @@ To know which version you have installed::
7676

7777
Running Tests
7878
======================
79-
At the moment, only redis back-end is available and therefore to run tests you need to install Redis_.
80-
If you are using linux, it can be achieved simply by downloading, uncompressing and running ``make``, if you are using
81-
windows and want to save yourself a headache you can download precompiled binaries at servicestack__.
79+
At the moment, only redis back-end is available and therefore to run tests you
80+
need to install Redis_. If you are using linux, it can be achieved simply
81+
by downloading, uncompressing and running ``make``, if you are using
82+
windows and want to save yourself a headache you can download precompiled
83+
binaries at servicestack__.
8284

8385
__ http://code.google.com/p/servicestack/wiki/RedisWindowsDownload
8486

85-
If you are running python 2.6, 3 and 3.1 you need to install the argparse_ package,
86-
which is a standard in python 2.7 and python >= 3.2.
87-
Once done that, open a shell and launch Redis. On another shell, from the package directory,
88-
type::
87+
Requirements for running tests
88+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89+
* unittest2_ for python 2.6 only.
90+
* argparse_ for python 2.6, 3 and 3.1 only.
91+
* nose_
92+
93+
Note, these requirements are only needed if you are planning to run tests.
94+
95+
Testing
96+
~~~~~~~~~~
97+
To run tests open a shell and launch Redis. On another shell,
98+
from the package directory, type::
8999

90100
python runtests.py
91101
92102
Tests are run against a local redis server on port 6379 and database 7 by default.
93-
To change the server and database where to run tests pass the ``-s`` option as follow::
103+
To change the server and database where to run tests pass the ``--server`` option as follow::
94104

95-
python runtests.py -s redis://myserver.com:6450/?db=12
105+
python runtests.py --server redis://myserver.com:6450/?db=12
96106

97107
For more information type::
98108

@@ -104,7 +114,7 @@ To access coverage of tests you need to install the coverage_ package and run th
104114
105115
and to check out the coverage report::
106116

107-
coverage report -m
117+
coverage html
108118

109119

110120
Backends
@@ -224,4 +234,6 @@ file in the top distribution directory for the full license text.
224234
.. _BSD: http://www.opensource.org/licenses/bsd-license.php
225235
.. _Sphinx: http://sphinx.pocoo.org/
226236
.. _coverage: http://nedbatchelder.com/code/coverage/
227-
.. _argparse: http://pypi.python.org/pypi/argparse
237+
.. _argparse: http://pypi.python.org/pypi/argparse
238+
.. _unittest2: http://pypi.python.org/pypi/unittest2
239+
.. _nose: http://readthedocs.org/docs/nose/en/latest

examples/data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ class FinanceTest(test.TestCase):
168168

169169
@classmethod
170170
def setUpClass(cls):
171-
size = cls.worker.cfg.size
172-
cls.data = finance_data(size = size)
171+
cls.data = finance_data(size = cls.size)
173172

174173

175174

runtests.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
import os
66

77
from stdnet.conf import settings
8-
from stdnet.utils import PPath
8+
from stdnet.utils import Path
99
from stdnet import getdb
1010

11-
PPath(__file__).add(module = 'pulsar', up = 1, down = ('pulsar',))
11+
## This is for dev environment with pulsar and dynts.
12+
## If not available, some tests won't run
13+
p = Path(__file__)
14+
p.add2python('pulsar', up=1, down=('pulsar',), must_exist=False)
15+
p.add2python('synts', up=1, down=('dynts',), must_exist=False)
1216

13-
from stdnet.test import nose, pulsar, TestServer, StdnetServer
17+
from stdnet.test import nose, pulsar
1418

1519

1620
def noseoption(argv,*vals,**kwargs):
@@ -33,21 +37,25 @@ def start():
3337
if pulsar:
3438
from pulsar.apps.test import TestSuite
3539
from pulsar.apps.test.plugins import bench
40+
from stdnet.test import PulsarStdnetServer, PulsarDataSizePlugin
3641

3742
os.environ['stdnet_test_suite'] = 'pulsar'
3843
suite = TestSuite(
3944
description = 'Stdnet Asynchronous test suite',
4045
modules = ('tests',),
41-
plugins = (TestServer(),
46+
plugins = (PulsarStdnetServer(),
47+
PulsarDataSizePlugin(),
4248
bench.BenchMark(),)
4349
)
4450
suite.start()
4551
elif nose:
52+
from stdnet.test import NoseDataSizePlugin, NoseStdnetServer
4653
os.environ['stdnet_test_suite'] = 'nose'
4754
argv = list(sys.argv)
4855
noseoption(argv, '-w', value = 'tests/regression')
4956
noseoption(argv, '--all-modules')
50-
nose.main(argv=argv, addplugins=[StdnetServer()])
57+
nose.main(argv=argv, addplugins=[NoseStdnetServer(),
58+
NoseDataSizePlugin()])
5159
else:
5260
print('To run tests you need either pulsar or nose.')
5361
exit(0)

stdnet/lib/redis/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454

5555
from stdnet import BackendRequest
5656
from stdnet.conf import settings
57-
from stdnet.utils import to_bytestring, iteritems, map, ispy3k, range,\
58-
to_string
57+
from stdnet.utils import iteritems, map, ispy3k, range, to_string
5958
from stdnet.lib import RedisReader, fallback
6059
from stdnet.utils.dispatch import Signal
6160

stdnet/orm/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import weakref
66

77
from stdnet import BackendRequest, AsyncObject
8-
from stdnet.utils import zip, to_bytestring, to_string
8+
from stdnet.utils import zip, to_string
99
from stdnet.exceptions import *
1010

1111
from . import signals

stdnet/orm/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from stdnet.utils import pickle, DefaultJSONEncoder,\
1111
DefaultJSONHook, timestamp2date, date2timestamp,\
1212
UnicodeMixin, to_string, is_string,\
13-
to_bytestring, is_bytes_or_string, iteritems,\
13+
is_bytes_or_string, iteritems,\
1414
encoders, flat_to_nested, dict_flat_generator,\
1515
string_type
1616

stdnet/orm/globals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import hashlib
22

3-
from stdnet.utils import to_bytestring, JSPLITTER
3+
from stdnet.utils import to_bytes, JSPLITTER
44

55
__all__ = ['get_model_from_hash', 'hashmodel', 'JSPLITTER']
66

@@ -15,7 +15,7 @@ def hashmodel(model, library = None):
1515
'''Calculate the Hash id of metaclass ``meta``'''
1616
library = library or 'python-stdnet'
1717
meta = model._meta
18-
sha = hashlib.sha1(to_bytestring('{0}({1})'.format(library,meta)))
18+
sha = hashlib.sha1(to_bytes('{0}({1})'.format(library,meta)))
1919
hash = sha.hexdigest()[:8]
2020
meta.hash = hash
2121
if hash in _model_dict:

stdnet/orm/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from inspect import isgenerator
33

44
from stdnet.exceptions import *
5-
from stdnet.utils import zip, to_bytestring, JSPLITTER
5+
from stdnet.utils import zip, JSPLITTER
66

77
from .signals import *
88

0 commit comments

Comments
 (0)