Add upgrade sql scripts
Ignore-this: dd6070080d744fb40683f0ff4421bf9c darcs-hash:20090217200445-86b55-d3e2a47f7830be8d887e1101e4ca3e9e6912e3dd.gz
This commit is contained in:
@@ -11,4 +11,4 @@ CREATE TABLE account (
|
|||||||
lastlogin TIMESTAMP,
|
lastlogin TIMESTAMP,
|
||||||
user_id INT CONSTRAINT user_id_exists REFERENCES user_table(id) ,
|
user_id INT CONSTRAINT user_id_exists REFERENCES user_table(id) ,
|
||||||
child_name VARCHAR (255)
|
child_name VARCHAR (255)
|
||||||
)
|
);
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ CREATE TABLE legacy_j_id (
|
|||||||
jid TEXT,
|
jid TEXT,
|
||||||
account_id INT CONSTRAINT account_id_exists REFERENCES account(id) ,
|
account_id INT CONSTRAINT account_id_exists REFERENCES account(id) ,
|
||||||
child_name VARCHAR (255)
|
child_name VARCHAR (255)
|
||||||
)
|
);
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ CREATE TABLE presence_account (
|
|||||||
dnd_action INT,
|
dnd_action INT,
|
||||||
offline_action INT,
|
offline_action INT,
|
||||||
child_name VARCHAR (255)
|
child_name VARCHAR (255)
|
||||||
)
|
);
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ CREATE TABLE user_table (
|
|||||||
jid TEXT,
|
jid TEXT,
|
||||||
has_received_motd BOOLEAN,
|
has_received_motd BOOLEAN,
|
||||||
child_name VARCHAR (255)
|
child_name VARCHAR (255)
|
||||||
)
|
);
|
||||||
|
|||||||
29
sqlobject_history/2008-11-09/upgrade_sqlite_2009-02-17.sql
Normal file
29
sqlobject_history/2008-11-09/upgrade_sqlite_2009-02-17.sql
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
begin transaction;
|
||||||
|
CREATE TEMPORARY TABLE account_backup (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
jid TEXT,
|
||||||
|
status TEXT,
|
||||||
|
error TEXT,
|
||||||
|
enabled BOOLEAN,
|
||||||
|
lastlogin TIMESTAMP,
|
||||||
|
user_id INT CONSTRAINT user_id_exists REFERENCES user_table(id) ,
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
|
INSERT INTO account_backup SELECT * FROM account;
|
||||||
|
DROP TABLE account;
|
||||||
|
CREATE TABLE account (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
jid TEXT,
|
||||||
|
status TEXT,
|
||||||
|
error TEXT,
|
||||||
|
enabled BOOLEAN,
|
||||||
|
lastlogin TIMESTAMP,
|
||||||
|
user_table_id INT CONSTRAINT user_table_id_exists REFERENCES user_table(id),
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
|
INSERT INTO account SELECT * FROM account_backup;
|
||||||
|
DROP TABLE account_backup;
|
||||||
|
commit;
|
||||||
|
|
||||||
14
sqlobject_history/2009-02-17/Account_sqlite.sql
Normal file
14
sqlobject_history/2009-02-17/Account_sqlite.sql
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- Exported definition from 2009-02-17T13:58:34
|
||||||
|
-- Class jcl.model.account.Account
|
||||||
|
-- Database: sqlite
|
||||||
|
CREATE TABLE account (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
jid TEXT,
|
||||||
|
status TEXT,
|
||||||
|
error TEXT,
|
||||||
|
enabled BOOLEAN,
|
||||||
|
lastlogin TIMESTAMP,
|
||||||
|
user_table_id INT CONSTRAINT user_table_id_exists REFERENCES user_table(id),
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
10
sqlobject_history/2009-02-17/LegacyJID_sqlite.sql
Normal file
10
sqlobject_history/2009-02-17/LegacyJID_sqlite.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- Exported definition from 2009-02-17T13:58:34
|
||||||
|
-- Class jcl.model.account.LegacyJID
|
||||||
|
-- Database: sqlite
|
||||||
|
CREATE TABLE legacy_j_id (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
legacy_address TEXT,
|
||||||
|
jid TEXT,
|
||||||
|
account_id INT CONSTRAINT account_id_exists REFERENCES account(id) ,
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
13
sqlobject_history/2009-02-17/PresenceAccount_sqlite.sql
Normal file
13
sqlobject_history/2009-02-17/PresenceAccount_sqlite.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- Exported definition from 2009-02-17T13:58:34
|
||||||
|
-- Class jcl.model.account.PresenceAccount
|
||||||
|
-- Database: sqlite
|
||||||
|
CREATE TABLE presence_account (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
chat_action INT,
|
||||||
|
online_action INT,
|
||||||
|
away_action INT,
|
||||||
|
xa_action INT,
|
||||||
|
dnd_action INT,
|
||||||
|
offline_action INT,
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
9
sqlobject_history/2009-02-17/User_sqlite.sql
Normal file
9
sqlobject_history/2009-02-17/User_sqlite.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
-- Exported definition from 2009-02-17T13:58:34
|
||||||
|
-- Class jcl.model.account.User
|
||||||
|
-- Database: sqlite
|
||||||
|
CREATE TABLE user_table (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
jid TEXT,
|
||||||
|
has_received_motd BOOLEAN,
|
||||||
|
child_name VARCHAR (255)
|
||||||
|
);
|
||||||
99
src/jcl/jabber/tests/register.py
Normal file
99
src/jcl/jabber/tests/register.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## register.py
|
||||||
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
|
## Started on Fri Jul 6 21:40:55 2007 David Rousselie
|
||||||
|
## $Id$
|
||||||
|
##
|
||||||
|
## Copyright (C) 2007 David Rousselie
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License
|
||||||
|
## along with this program; if not, write to the Free Software
|
||||||
|
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
##
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from pyxmpp.iq import Iq
|
||||||
|
from pyxmpp.jabber.dataforms import Form
|
||||||
|
|
||||||
|
from jcl.tests import JCLTestCase
|
||||||
|
from jcl.model.tests.account import ExampleAccount
|
||||||
|
|
||||||
|
from jcl.lang import Lang
|
||||||
|
from jcl.model.account import User, Account
|
||||||
|
from jcl.jabber.component import JCLComponent
|
||||||
|
from jcl.jabber.register import SetRegisterHandler
|
||||||
|
|
||||||
|
class SetRegisterHandler_TestCase(JCLTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
JCLTestCase.setUp(self, tables=[User, Account, ExampleAccount])
|
||||||
|
self.comp = JCLComponent("jcl.test.com",
|
||||||
|
"password",
|
||||||
|
"localhost",
|
||||||
|
"5347",
|
||||||
|
self.db_url)
|
||||||
|
self.handler = SetRegisterHandler(self.comp)
|
||||||
|
|
||||||
|
def test_handle_valid_name(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="good_name",
|
||||||
|
field_type="text-single")
|
||||||
|
result = self.handler.handle(iq_set, Lang.en, None, x_data)
|
||||||
|
self.assertEquals(result, None)
|
||||||
|
|
||||||
|
def test_handle_invalid_name(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",
|
||||||
|
from_jid="user1@test.com/res",
|
||||||
|
to_jid="jcl.test.com")
|
||||||
|
x_data = Form("submit")
|
||||||
|
x_data.add_field(name="name",
|
||||||
|
value="",
|
||||||
|
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.mandatory_field))
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
test_suite = unittest.TestSuite()
|
||||||
|
test_suite.addTest(unittest.makeSuite(SetRegisterHandler_TestCase, 'test'))
|
||||||
|
return test_suite
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(defaultTest='suite')
|
||||||
Reference in New Issue
Block a user