Required field XMPP error found

* "not-acceptable" error sent when required field is not found

darcs-hash:20061120215831-86b55-460f3114e75cd77f263800d0a32dbf27add094eb.gz
This commit is contained in:
David Rousselie
2006-11-20 22:58:31 +01:00
parent 521f3cd892
commit 30979f1142
3 changed files with 10 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ if __name__ == '__main__':
sender_suite = unittest.makeSuite(Sender_TestCase, "test")
jcl_suite = unittest.TestSuite()
# jcl_suite.addTest(FeederComponent_TestCase('test_handle_tick'))
# jcl_suite.addTest(FeederComponent_TestCase('test_handle_presence_available_to_account_live_password'))
# jcl_suite.addTest(FeederComponent_TestCase('test_handle_set_register_new_field_mandatory'))
# jcl_suite = unittest.TestSuite((feeder_component_suite))
# jcl_suite = unittest.TestSuite((component_suite))
jcl_suite = unittest.TestSuite((component_suite,

View File

@@ -358,9 +358,8 @@ class JCLComponent(Component, object):
x_data.from_xml(query.children)
name = x_data.get_field_value("name")
if name is None:
# TODO : find correct error for mandatory field
info_query = info_query.make_error_response(\
"resource-constraint")
"not-acceptable")
self.stream.send(info_query)
return
self.db_connect()
@@ -390,8 +389,7 @@ class JCLComponent(Component, object):
field_default_func))
except FieldError, exception:
_account.destroySelf()
# TODO: get correct error from exception
info_query = info_query.make_error_response("resource-constraint")
info_query = info_query.make_error_response("not-acceptable")
self.stream.send(info_query)
self.db_disconnect()
return

View File

@@ -751,7 +751,9 @@ class JCLComponent_TestCase(unittest.TestCase):
stanza_sent = self.comp.stream.sent
self.assertEquals(len(stanza_sent), 1)
self.assertTrue(isinstance(stanza_sent[0], Iq))
# TODO : add more assertions need to find the correct exception
self.assertEquals(stanza_sent[0].get_node().prop("type"), "error")
error = stanza_sent[0].get_error()
self.assertEquals(error.get_condition().name, "not-acceptable")
def test_handle_set_register_new_field_mandatory(self):
self.comp.account_class = AccountExample
@@ -780,8 +782,10 @@ class JCLComponent_TestCase(unittest.TestCase):
stanza_sent = self.comp.stream.sent
self.assertEquals(len(stanza_sent), 1)
self.assertTrue(isinstance(stanza_sent[0], Iq))
# TODO : add more assertions need to find the correct exception
self.assertEquals(stanza_sent[0].get_node().prop("type"), "error")
error = stanza_sent[0].get_error()
self.assertEquals(error.get_condition().name, "not-acceptable")
def test_handle_set_register_update_complex(self):
self.comp.account_class = AccountExample
self.comp.stream = MockStream()