'get-online-users-num' ad-hoc command implementation
darcs-hash:20070808161155-86b55-27f84d856cca045c9d91e7f9aa5059134aefd9f7.gz
This commit is contained in:
@@ -639,29 +639,20 @@ class JCLCommandManager(CommandManager):
|
|||||||
command_node.setProp("status", STATUS_COMPLETED)
|
command_node.setProp("status", STATUS_COMPLETED)
|
||||||
return (result_form, [])
|
return (result_form, [])
|
||||||
|
|
||||||
def execute_add_to_blacklist_in(self, info_query):
|
def execute_get_online_users_num_1(self, info_query, session_context,
|
||||||
return []
|
command_node, lang_class):
|
||||||
|
result_form = Form(xmlnode_or_type="result")
|
||||||
def execute_add_to_blacklist_out(self, info_query):
|
result_form.add_field(field_type="hidden",
|
||||||
return []
|
name="FORM_TYPE",
|
||||||
|
value="http://jabber.org/protocol/admin")
|
||||||
def execute_edit_whitelist(self, info_query):
|
num_accounts = account.get_all_accounts_count(\
|
||||||
return []
|
filter=(Account.q._status != account.OFFLINE))
|
||||||
|
result_form.fields.append(FieldNoType(name="onlineusersnum",
|
||||||
def execute_add_to_whitelist_in(self, info_query):
|
label="TODO",
|
||||||
return []
|
value=num_accounts))
|
||||||
|
result_form.as_xml(command_node)
|
||||||
def execute_add_to_whitelist_out(self, info_query):
|
command_node.setProp("status", STATUS_COMPLETED)
|
||||||
return []
|
return (result_form, [])
|
||||||
|
|
||||||
def execute_get_registered_users_num(self, info_query):
|
|
||||||
return []
|
|
||||||
|
|
||||||
def execute_get_disabled_users_num(self, info_query):
|
|
||||||
return []
|
|
||||||
|
|
||||||
def execute_get_online_users_num(self, info_query):
|
|
||||||
return []
|
|
||||||
|
|
||||||
def execute_get_active_users_num(self, info_query):
|
def execute_get_active_users_num(self, info_query):
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -1592,77 +1592,48 @@ class JCLCommandManager_TestCase(JCLTestCase):
|
|||||||
self.assertEquals(fields[1].children.name, "value")
|
self.assertEquals(fields[1].children.name, "value")
|
||||||
self.assertEquals(fields[1].children.content, "2")
|
self.assertEquals(fields[1].children.content, "2")
|
||||||
|
|
||||||
# def test_execute_add_to_blacklist_in(self):
|
def test_execute_get_online_users_num(self):
|
||||||
# #TODO : implement command
|
self.comp.account_manager.account_classes = (ExampleAccount,
|
||||||
# info_query = Iq(stanza_type="set",
|
Example2Account)
|
||||||
# from_jid="user1@test.com",
|
model.db_connect()
|
||||||
# to_jid="jcl.test.com")
|
account11 = ExampleAccount(user_jid="test1@test.com",
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
name="account11",
|
||||||
# self.assertNotEquals(result, None)
|
jid="account11@jcl.test.com")
|
||||||
# self.assertEquals(len(result), 1)
|
account11.status = account.ONLINE
|
||||||
|
account12 = Example2Account(user_jid="test1@test.com",
|
||||||
# def test_execute_add_to_blacklist_out(self):
|
name="account12",
|
||||||
# #TODO : implement command
|
jid="account12@jcl.test.com")
|
||||||
# info_query = Iq(stanza_type="set",
|
account12.status = "away"
|
||||||
# from_jid="user1@test.com",
|
account21 = ExampleAccount(user_jid="test2@test.com",
|
||||||
# to_jid="jcl.test.com")
|
name="account21",
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
jid="account21@jcl.test.com")
|
||||||
# self.assertNotEquals(result, None)
|
account22 = ExampleAccount(user_jid="test2@test.com",
|
||||||
# self.assertEquals(len(result), 1)
|
name="account11",
|
||||||
|
jid="account11@jcl.test.com")
|
||||||
# def test_execute_edit_whitelist(self):
|
account22.status = "chat"
|
||||||
# #TODO : implement command
|
model.db_disconnect()
|
||||||
# info_query = Iq(stanza_type="set",
|
info_query = Iq(stanza_type="set",
|
||||||
# from_jid="user1@test.com",
|
from_jid="user1@test.com",
|
||||||
# to_jid="jcl.test.com")
|
to_jid="jcl.test.com")
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
command_node = info_query.set_new_content(command.COMMAND_NS, "command")
|
||||||
# self.assertNotEquals(result, None)
|
command_node.setProp("node", "http://jabber.org/protocol/admin#get-online-users-num")
|
||||||
# self.assertEquals(len(result), 1)
|
result = self.command_manager.apply_command_action(info_query,
|
||||||
|
"http://jabber.org/protocol/admin#get-online-users-num",
|
||||||
# def test_execute_add_to_whitelist_in(self):
|
"execute")
|
||||||
# #TODO : implement command
|
self.assertNotEquals(result, None)
|
||||||
# info_query = Iq(stanza_type="set",
|
self.assertEquals(len(result), 1)
|
||||||
# from_jid="user1@test.com",
|
xml_command = result[0].xpath_eval("c:command",
|
||||||
# to_jid="jcl.test.com")
|
{"c": "http://jabber.org/protocol/commands"})[0]
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
self.assertEquals(xml_command.prop("status"), "completed")
|
||||||
# self.assertNotEquals(result, None)
|
self.assertNotEquals(xml_command.prop("sessionid"), None)
|
||||||
# self.assertEquals(len(result), 1)
|
self.__check_actions(result[0])
|
||||||
|
fields = result[0].xpath_eval("c:command/data:x/data:field",
|
||||||
# def test_execute_add_to_whitelist_out(self):
|
{"c": "http://jabber.org/protocol/commands",
|
||||||
# #TODO : implement command
|
"data": "jabber:x:data"})
|
||||||
# info_query = Iq(stanza_type="set",
|
self.assertEquals(len(fields), 2)
|
||||||
# from_jid="user1@test.com",
|
self.assertEquals(fields[1].prop("var"), "onlineusersnum")
|
||||||
# to_jid="jcl.test.com")
|
self.assertEquals(fields[1].children.name, "value")
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
self.assertEquals(fields[1].children.content, "3")
|
||||||
# self.assertNotEquals(result, None)
|
|
||||||
# self.assertEquals(len(result), 1)
|
|
||||||
|
|
||||||
# def test_execute_get_registered_users_num(self):
|
|
||||||
# #TODO : implement command
|
|
||||||
# info_query = Iq(stanza_type="set",
|
|
||||||
# from_jid="user1@test.com",
|
|
||||||
# to_jid="jcl.test.com")
|
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
|
||||||
# self.assertNotEquals(result, None)
|
|
||||||
# self.assertEquals(len(result), 1)
|
|
||||||
|
|
||||||
# def test_execute_get_disabled_users_num(self):
|
|
||||||
# #TODO : implement command
|
|
||||||
# info_query = Iq(stanza_type="set",
|
|
||||||
# from_jid="user1@test.com",
|
|
||||||
# to_jid="jcl.test.com")
|
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
|
||||||
# self.assertNotEquals(result, None)
|
|
||||||
# self.assertEquals(len(result), 1)
|
|
||||||
|
|
||||||
# def test_execute_get_online_users_num(self):
|
|
||||||
# #TODO : implement command
|
|
||||||
# info_query = Iq(stanza_type="set",
|
|
||||||
# from_jid="user1@test.com",
|
|
||||||
# to_jid="jcl.test.com")
|
|
||||||
# result = self.command_manager.execute_add_user(info_query)
|
|
||||||
# self.assertNotEquals(result, None)
|
|
||||||
# self.assertEquals(len(result), 1)
|
|
||||||
|
|
||||||
# def test_execute_get_active_users_num(self):
|
# def test_execute_get_active_users_num(self):
|
||||||
# #TODO : implement command
|
# #TODO : implement command
|
||||||
|
|||||||
Reference in New Issue
Block a user