Files
jcl/debian/patches/debian-changes-0.1b3
David Rousselie 348f5ce37e Fix tests
2010-06-09 13:46:38 +02:00

212 lines
7.8 KiB
Plaintext

Description: Upstream changes introduced in version 0.1b3
This patch has been created by dpkg-source during the package build.
Here's the last changelog entry, hopefully it gives details on why
those changes were made:
.
jcl (0.1b3) unstable; urgency=low
.
* JCL v0.1 beta 3
.
The person named in the Author field signed this changelog entry.
Author: David Rousselie <dax@happycoders.org>
---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>
--- jcl-0.1b3.orig/Makefile
+++ jcl-0.1b3/Makefile
@@ -2,7 +2,7 @@ PYTHON=`which python`
DESTDIR=/
BUILDIR=$(CURDIR)/debian/jcl
PROJECT=jcl
-VERSION=0.1b2
+VERSION=0.1b3
all:
@echo "make source - Create source package"
@@ -23,7 +23,7 @@ buildrpm:
builddeb:
$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../
rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
- dpkg-buildpackage -i -I -rfakeroot
+ dpkg-buildpackage -us -uc -i -I -rfakeroot
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
result = self.handler.handle(iq_set, Lang.en, None, x_data)
self.assertEquals(result, None)
- def test_handle_invalid_name(self):
+ def test_handle_invalid_name_with_invalid_char(self):
"""Test with invalid supplied name"""
iq_set = Iq(stanza_type="set",
from_jid="user1@test.com/res",
@@ -73,6 +73,23 @@ class SetRegisterHandler_TestCase(JCLTes
self.assertEquals(error.get_text(), Lang.en.field_error \
% ("name", Lang.en.arobase_in_name_forbidden))
+ def test_handle_invalid_name_with_whitespace(self):
+ """Test with invalid supplied name"""
+ iq_set = Iq(stanza_type="set",
+ from_jid="user1@test.com/res",
+ to_jid="jcl.test.com")
+ x_data = Form("submit")
+ x_data.add_field(name="name",
+ value="wrong name",
+ field_type="text-single")
+ result = self.handler.handle(iq_set, Lang.en, None, x_data)
+ self.assertEquals(len(result), 1)
+ self.assertEquals(result[0].xmlnode.prop("type"), "error")
+ error = result[0].get_error()
+ self.assertEquals(error.get_condition().name, "not-acceptable")
+ self.assertEquals(error.get_text(), Lang.en.field_error \
+ % ("name", Lang.en.arobase_in_name_forbidden))
+
def test_handle_invalid_empty_name(self):
"""Test with empty supplied name"""
iq_set = Iq(stanza_type="set",