Permalink
Browse files

More tests

  • Loading branch information...
alex committed Apr 14, 2010
1 parent f95977a commit de049586f587d64dab6a26b5e31d862171fe09f1
Showing with 31 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +29 −1 agon/tests.py
  3. +1 −0 requirements.txt
View
@@ -1,2 +1,3 @@
MANIFEST
dist
+*.py[co]
View
@@ -1,3 +1,5 @@
+from threading import Thread
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
@@ -7,8 +9,8 @@
from agon.models import award_points, points_awarded
+
class PointsTestCase(TestCase):
-
def setup_points(self, value):
settings.AGON_POINT_VALUES = value
@@ -31,3 +33,29 @@ def test_simple_user_point_award(self):
user = User.objects.create_user("brian", "someone@example.com", "abc123")
award_points(user, "JOINED_SITE")
self.assertEqual(points_awarded(user), 1)
+
+class AgonTestCase(TestCase):
+ def setUp(self):
+ settings.AGON_POINT_VALUES = {
+ "TEST_1": 10,
+ }
+ self.users = [
+ User.objects.create_user("user_%d" % i, "user_%d@example.com" % i, str(i))
+ for i in xrange(1)
+ ]
+
+ def tearDown(self):
+ del settings.AGON_POINT_VALUES
+
+ def test_concurrent_award(self):
+ user = self.users[0]
+ def run():
+ award_points(user, "TEST_1")
+ threads = []
+ for i in xrange(5):
+ t = Thread(target=run)
+ threads.append(t)
+ t.start()
+ for t in threads:
+ t.join()
+ self.assertEqual(points_awarded(user), 50)
View
@@ -0,0 +1 @@
+-e git+git://github.com/brosner/django-app-test-runner.git#egg=app_test_runner

0 comments on commit de04958

Please sign in to comment.