Skip to content

Commit

Permalink
Adding coverage and flake8 to the build; running complete build for t…
Browse files Browse the repository at this point in the history
…ravis-ci
  • Loading branch information
diogobaeder committed Feb 8, 2013
1 parent 03246e1 commit 5ad27f3
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@
#*#
build/
dist/
.coverage
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,4 +4,4 @@ python:
# command to install dependencies
install: pip install -r requirements --use-mirrors
# command to run tests
script: nosetests
script: make build
8 changes: 8 additions & 0 deletions Makefile
@@ -0,0 +1,8 @@
test:
@env PYTHONHASHSEED=random PYTHONPATH=. nosetests --with-coverage --cover-package=pycket --cover-erase --with-yanc --with-xtraceback tests/

lint:
@echo Running syntax check...
@flake8 . --ignore=E501

build: test lint
2 changes: 1 addition & 1 deletion pycket/driver.py
Expand Up @@ -87,4 +87,4 @@ def _create_redis(self, storage_settings, storage_category):
return RedisDriver(storage_settings)

def _create_memcached(self, storage_settings, storage_category):
return MemcachedDriver(storage_settings)
return MemcachedDriver(storage_settings)
4 changes: 2 additions & 2 deletions pycket/notification.py
Expand Up @@ -8,7 +8,7 @@
in the "storage" setting.)
'''

from pycket.session import create_mixin, SessionManager, SessionMixin
from pycket.session import create_mixin, SessionManager


class NotificationManager(SessionManager):
Expand All @@ -34,4 +34,4 @@ def notifications(self):
Returns a NotificationManager instance
'''

return create_mixin(self, '__notification_manager', NotificationManager)
return create_mixin(self, '__notification_manager', NotificationManager)
2 changes: 1 addition & 1 deletion pycket/session.py
Expand Up @@ -194,4 +194,4 @@ class ConfigurationError(Exception):
def create_mixin(context, manager_property, manager_class):
if not hasattr(context, manager_property):
setattr(context, manager_property, manager_class(context))
return getattr(context, manager_property)
return getattr(context, manager_property)
17 changes: 12 additions & 5 deletions requirements
@@ -1,6 +1,13 @@
coverage==3.5.1
nose==1.1.2
python-memcached==1.47
redis==2.4.9
tornado==2.1.1
Pygments==1.6
argparse==1.2.1
coverage==3.6
flake8==1.7.0
nose==1.2.1
nose-notify==0.4.2
python-memcached==1.48
redis==2.7.2
termcolor==1.0.1
tornado==2.4.1
wsgiref==0.1.2
xtraceback==0.3.3
yanc==0.2.3
10 changes: 4 additions & 6 deletions setup.py
@@ -1,17 +1,15 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
import sys, os

version = '0.2.0'

setup(name='pycket',
version=version,
description="Redis/Memcached sessions for Tornado",
long_description="Redis/Memcached sessions for Tornado (see GitHub page for more info)",
classifiers=[
'Topic :: Internet :: WWW/HTTP :: Session',
'Topic :: Database',
], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=['Topic :: Internet :: WWW/HTTP :: Session',
'Topic :: Database',
],
keywords='pycket redis memcached tornado session python',
author='Diogo Baeder',
author_email='desenvolvedor@diogobaeder.com.br',
Expand All @@ -28,4 +26,4 @@
""",
test_suite="nose.collector",
tests_require="nose",
)
)
2 changes: 1 addition & 1 deletion tests/test_driver.py
Expand Up @@ -176,4 +176,4 @@ def creates_instance_for_memcached_session(self):
def cannot_create_a_driver_for_not_supported_engine(self):
factory = DriverFactory()

instance = factory.create('cassete-tape', storage_settings={}, storage_category='db_sessions')
factory.create('cassete-tape', storage_settings={}, storage_category='db_sessions')
7 changes: 3 additions & 4 deletions tests/test_functional.py
@@ -1,12 +1,10 @@
import pickle

from nose.tools import istest
import redis
from tornado.testing import AsyncHTTPTestCase
from tornado.web import Application, RequestHandler

from pycket.driver import RedisDriver
from pycket.session import SessionManager, SessionMixin
from pycket.session import SessionMixin


class FunctionalTest(AsyncHTTPTestCase):
Expand All @@ -19,6 +17,7 @@ def setUp(self):
def get_app(self):
if self.dataset is None:
self.dataset = redis.Redis(db=RedisDriver.DEFAULT_STORAGE_IDENTIFIERS['db_sessions'])

class SimpleHandler(RequestHandler, SessionMixin):
def get(self):
self.session.set('foo', 'bar')
Expand All @@ -45,4 +44,4 @@ def works_with_request_handlers(self):
self.assertEqual(response.code, 200)
self.assertIn('bar', response.body)

self.assertEqual(len(self.dataset.keys()), 1)
self.assertEqual(len(self.dataset.keys()), 1)
3 changes: 1 addition & 2 deletions tests/test_notification.py
@@ -1,12 +1,11 @@
import pickle
import time
from unittest import TestCase

from nose.tools import istest
import redis

from pycket.driver import RedisDriver
from pycket.session import SessionManager, SessionMixin
from pycket.session import SessionMixin
from pycket.notification import NotificationManager, NotificationMixin


Expand Down
12 changes: 8 additions & 4 deletions tests/test_session.py
@@ -1,6 +1,6 @@
import pickle
import time
from unittest import skip, skipIf, TestCase
from unittest import skipIf, TestCase

from nose.tools import istest, raises
import redis
Expand Down Expand Up @@ -87,6 +87,7 @@ class StubHandler(SessionMixin):
'engine': 'redis',
}
}

def get_secure_cookie(self, name):
test_case.assertEqual(name, 'PYCKET_ID')
self.cookie_set = True
Expand All @@ -107,14 +108,13 @@ def set_secure_cookie(self, name, value, expires_days, expires):

@istest
def does_not_set_session_id_if_already_exists(self):
test_case = self

class StubHandler(SessionMixin):
settings = {
'pycket': {
'engine': 'redis',
}
}

def get_secure_cookie(self, name):
self.cookie_retrieved = True
return 'some-id'
Expand Down Expand Up @@ -248,6 +248,7 @@ class StubHandler(SessionMixin):
'engine': 'redis',
}
}

def get_secure_cookie(self, name):
return None

Expand All @@ -272,6 +273,7 @@ class StubHandler(SessionMixin):
}
},
}

def get_secure_cookie(self, name):
return None

Expand All @@ -295,6 +297,7 @@ class StubHandler(SessionMixin):
}
},
}

def get_secure_cookie(self, name):
return None

Expand All @@ -318,6 +321,7 @@ class StubHandler(SessionMixin):
}
},
}

def get_secure_cookie(self, name):
return None

Expand Down Expand Up @@ -388,7 +392,7 @@ def gets_all_available_keys_from_session(self):
manager.set('foo', 'FOO')
manager.set('bar', 'BAR')

self.assertListEqual(manager.keys(), ['foo', 'bar'])
self.assertListEqual(sorted(manager.keys()), sorted(['foo', 'bar']))

@istest
def iterates_with_method_over_keys(self):
Expand Down

0 comments on commit 5ad27f3

Please sign in to comment.