Skip to content

Commit

Permalink
Add tox
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanoch committed Sep 21, 2015
1 parent 624b511 commit 29d4b03
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 284 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = setup.py
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ develop-eggs
pip-log.txt

# Unit test / coverage reports
coverage.xml
.coverage
.tox

#Mr Developer
.mr.developer.cfg

/.eggs/
/.eggs/
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Test
You can run the tests with
::

python setup.py test
tox

Wishlist
--------
Expand All @@ -45,6 +45,8 @@ Wishlist

Releases
--------
v1.2.0:
Move id to UUIDField, add code quality checks and CI
v1.1.0:
Rename model to NonBlockingLock and add additional features
v1.0.1:
Expand Down
5 changes: 4 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ machine:

test:
override:
- python setup.py test
- tox
post:
- pip install codecov
- codecov --token=${CODECOV_TOKEN}
4 changes: 4 additions & 0 deletions deployment/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Django
freezegun
tox
coverage
17 changes: 1 addition & 16 deletions locking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
#: The version list
VERSION = (1, 1, 0)


def get_version():
'''
Converts the :attr:`VERSION` into a nice string
'''
if len(VERSION) > 3 and VERSION[3] not in ('final', ''):
return '%s.%s.%s %s' % (VERSION[0], VERSION[1], VERSION[2], VERSION[3])
else:
return '%s.%s.%s' % (VERSION[0], VERSION[1], VERSION[2])


#: The version python displays
__version__ = get_version()
__version__ = '1.2.0'
51 changes: 0 additions & 51 deletions locking/south_migrations/0001_initial.py

This file was deleted.

38 changes: 0 additions & 38 deletions locking/south_migrations/0002_added_lock_timeout.py

This file was deleted.

45 changes: 0 additions & 45 deletions locking/south_migrations/0003_auto__add_unique__added_index.py

This file was deleted.

This file was deleted.

39 changes: 0 additions & 39 deletions locking/south_migrations/0005_convert_to_str.py

This file was deleted.

51 changes: 0 additions & 51 deletions locking/south_migrations/0006_remove_generic_fk__made_unique.py

This file was deleted.

Empty file.
8 changes: 7 additions & 1 deletion locking/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from django.contrib.auth.models import User

from .exceptions import AlreadyLocked, RenewalError
from .exceptions import AlreadyLocked, RenewalError, NonexistentLock, NotLocked
from .models import NonBlockingLock, _get_lock_name


Expand All @@ -20,6 +20,8 @@ def setUp(self):

def test_acquire_and_release(self):
''' Tests an aquire/release cycle '''
self.assertRaises(NotLocked, NonBlockingLock.objects.release_lock, 0)

l = NonBlockingLock.objects.acquire_lock(self.user)
self.assertTrue(NonBlockingLock.objects.is_locked(self.user))
l.release()
Expand Down Expand Up @@ -47,6 +49,8 @@ def test_obj_with_expired_lock_is_not_locked(self):

def test_acquire_and_renew(self):
''' Tests an aquire/renew cycle '''
self.assertRaises(NonexistentLock, NonBlockingLock.objects.renew_lock, 0)

with freeze_time("2015-01-01 10:00"):
l = NonBlockingLock.objects.acquire_lock(self.user)
expires = l.expires_on
Expand Down Expand Up @@ -129,6 +133,8 @@ def test_clean_locks(self):
with freeze_time("2015-01-01 10:00"):
NonBlockingLock.objects.acquire_lock(self.user, max_age=1)

self.assertEqual(1, NonBlockingLock.objects.get_expired_locks().count())
call_command('clean_expired_locks', dry_run=True)
self.assertEqual(1, NonBlockingLock.objects.get_expired_locks().count())
call_command('clean_expired_locks')
self.assertEqual(0, NonBlockingLock.objects.get_expired_locks().count())
Loading

0 comments on commit 29d4b03

Please sign in to comment.