Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dax/jcl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rousselie <david.rousselie@happycoders.org>2010-06-09 15:46:38 +0400
committerDavid Rousselie <david.rousselie@happycoders.org>2010-06-09 15:46:38 +0400
commit348f5ce37e00cfd213cfa4ef133d90fd706fe732 (patch)
tree8df74e0f8e8b5b70c1a5803ca87f3962eebd8114
parent3d0d70c97674f96c811ba5fe46c1057cdd2125a2 (diff)
Fix tests
-rw-r--r--debian/patches/debian-changes-0.1b3132
-rw-r--r--src/jcl/model/tests/account.py7
2 files changed, 137 insertions, 2 deletions
diff --git a/debian/patches/debian-changes-0.1b3 b/debian/patches/debian-changes-0.1b3
index ebdaca1..62ae580 100644
--- a/debian/patches/debian-changes-0.1b3
+++ b/debian/patches/debian-changes-0.1b3
@@ -42,6 +42,138 @@ Last-Update: <YYYY-MM-DD>
clean:
$(PYTHON) setup.py clean
+--- /dev/null
++++ jcl-0.1b3/src/jcl/model/tests/__init___flymake.py
+@@ -0,0 +1,84 @@
++"""JCL test module"""
++__revision__ = ""
++
++import unittest
++import threading
++import os
++import tempfile
++import sys
++
++from sqlobject import SQLObject
++from sqlobject.col import StringCol
++from sqlobject.dbconnection import TheURIOpener
++
++import jcl.model as model
++
++if sys.platform == "win32":
++ DB_DIR = "/c|/temp/"
++else:
++ DB_DIR = "/tmp/"
++
++class MyMockSQLObject(SQLObject):
++ _connection = model.hub
++ string_attr = StringCol()
++
++class ModelModule_TestCase(unittest.TestCase):
++ def setUp(self):
++ self.db_path = tempfile.mktemp("db", "jcltest", DB_DIR)
++ if os.path.exists(self.db_path):
++ os.unlink(self.db_path)
++ self.db_url = "sqlite://" + self.db_path
++ model.db_connection_str = self.db_url
++ model.db_connect()
++ MyMockSQLObject.createTable(ifNotExists=True)
++ model.db_disconnect()
++
++ def tearDown(self):
++ model.db_connect()
++ MyMockSQLObject.dropTable(ifExists=True)
++ del TheURIOpener.cachedURIs[self.db_url]
++ model.hub.threadConnection.close()
++ model.db_disconnect()
++ if os.path.exists(self.db_path):
++ os.unlink(self.db_path)
++
++ def test_multiple_db_connection(self):
++ def create_account_thread():
++ for i in xrange(100):
++ string_attr = "obj2" + str(i)
++ model.db_connect()
++ obj = MyMockSQLObject(string_attr=string_attr)
++ model.db_disconnect()
++ model.db_connect()
++ obj2 = MyMockSQLObject.select(MyMockSQLObject.q.string_attr == string_attr)
++ model.db_disconnect()
++ self.assertEquals(obj, obj2[0])
++ timer_thread = threading.Thread(target=create_account_thread,
++ name="CreateAccountThread")
++ timer_thread.start()
++ for i in xrange(100):
++ string_attr = "obj1" + str(i)
++ model.db_connect()
++ obj = MyMockSQLObject(string_attr=string_attr)
++ model.db_disconnect()
++ model.db_connect()
++ obj2 = MyMockSQLObject.select(MyMockSQLObject.q.string_attr == string_attr)
++ model.db_disconnect()
++ self.assertEquals(obj, obj2[0])
++ timer_thread.join(2)
++ threads = threading.enumerate()
++ self.assertEquals(len(threads), 1)
++ model.db_connect()
++ objs = MyMockSQLObject.select()
++ self.assertEquals(objs.count(), 200)
++ model.db_disconnect()
++
++def suite():
++ suite = unittest.TestSuite()
++ suite.addTest(unittest.makeSuite(ModelModule_TestCase, 'test'))
++ from jcl.model.tests import account
++ suite.addTest(account.suite())
++ return suite
++
++if __name__ == '__main__':
++ unittest.main(defaultTest='suite')
+--- jcl-0.1b3.orig/src/jcl/model/tests/account.py
++++ jcl-0.1b3/src/jcl/model/tests/account.py
+@@ -137,6 +137,42 @@ class AccountModule_TestCase(JCLTestCase
+ "user1@jcl.test.com")
+ self.assertEquals(result, "test")
+
++ def test_boolean_post_func_with_1_str(self):
++ result = account.boolean_post_func("1", None, "user1@jcl.test.com")
++ self.assertEquals(result, True)
++
++ def test_boolean_post_func_with_True_str(self):
++ result = account.boolean_post_func("True", None, "user1@jcl.test.com")
++ self.assertEquals(result, True)
++
++ def test_boolean_post_func_with_False_str(self):
++ result = account.boolean_post_func("False", None, "user1@jcl.test.com")
++ self.assertEquals(result, False)
++
++ def test_boolean_post_func_with_1_unicode(self):
++ result = account.boolean_post_func(u"1", None, "user1@jcl.test.com")
++ self.assertEquals(result, True)
++
++ def test_boolean_post_func_with_True_unicode(self):
++ result = account.boolean_post_func(u"true", None, "user1@jcl.test.com")
++ self.assertEquals(result, True)
++
++ def test_boolean_post_func_with_False_unicode(self):
++ result = account.boolean_post_func(u"False", None, "user1@jcl.test.com")
++ self.assertEquals(result, False)
++
++ def test_boolean_post_func_with_1(self):
++ result = account.boolean_post_func(1, None, "user1@jcl.test.com")
++ self.assertEquals(result, False)
++
++ def test_boolean_post_func_with_True(self):
++ result = account.boolean_post_func(True, None, "user1@jcl.test.com")
++ self.assertEquals(result, True)
++
++ def test_boolean_post_func_with_False(self):
++ result = account.boolean_post_func(False, None, "user1@jcl.test.com")
++ self.assertEquals(result, False)
++
+ def test_int_post_func(self):
+ result = account.int_post_func("42", None, "user1@jcl.test.com")
+ self.assertEquals(result, 42)
--- jcl-0.1b3.orig/src/jcl/jabber/tests/register.py
+++ jcl-0.1b3/src/jcl/jabber/tests/register.py
@@ -56,7 +56,7 @@ class SetRegisterHandler_TestCase(JCLTes
diff --git a/src/jcl/model/tests/account.py b/src/jcl/model/tests/account.py
index 964d776..a7917a5 100644
--- a/src/jcl/model/tests/account.py
+++ b/src/jcl/model/tests/account.py
@@ -161,8 +161,8 @@ class AccountModule_TestCase(JCLTestCase):
result = account.boolean_post_func(u"False", None, "user1@jcl.test.com")
self.assertEquals(result, False)
- def test_boolean_post_func_with_1(self):
- result = account.boolean_post_func(1, None, "user1@jcl.test.com")
+ def test_boolean_post_func_with_0_str(self):
+ result = account.boolean_post_func("0", None, "user1@jcl.test.com")
self.assertEquals(result, False)
def test_boolean_post_func_with_True(self):
@@ -254,6 +254,9 @@ class AccountModule_TestCase(JCLTestCase):
self.assertEquals(_account.name, "account11")
class InheritableAccount_TestCase(JCLTestCase):
+ def setUp(self):
+ JCLTestCase.setUp(self, tables=[Account])
+ self.account_class = Account
def test_get_register_fields(self):
"""