changeset 2498:3b3b76b2225c

Add a test case for XmlRpcBase._generate_auth_token
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 05:09:26 +0200
parents e3bb982b4011
children b5a711a9ec09
files MoinMoin/xmlrpc/_tests/test_xmlrpc.py
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/xmlrpc/_tests/test_xmlrpc.py	Sun Jul 22 05:02:34 2007 +0200
+++ b/MoinMoin/xmlrpc/_tests/test_xmlrpc.py	Sun Jul 22 05:09:26 2007 +0200
@@ -1,18 +1,22 @@
 # -*- coding: iso-8859-1 -*-
 """
-    MoinMoin - MoinMoin.xmlrpc.xmlrpc_system_multicall Fault serialization
+    MoinMoin - tests for the xmlrpc module
 
     @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin.user import User
 from MoinMoin.xmlrpc import XmlRpcBase
 from xmlrpclib import Fault
 
-def xmlrpc_return_fault():
-    return Fault(666, "Fault description")
 
 def test_fault_serialization(request):
+    """test MoinMoin.xmlrpc.xmlrpc_system_multicall Fault serialization"""
+
+    def xmlrpc_return_fault():
+        return Fault(666, "Fault description")
+
     xmlrpc = XmlRpcBase(request)
     xmlrpc.xmlrpc_return_fault = xmlrpc_return_fault
     args = [{'methodName': 'return_fault', 'params': []}]
@@ -25,6 +29,17 @@
     assert type(result[0]) == dict
     assert result[0].has_key("faultCode") and result[0].has_key("faultString")
 
+def test_generate_auth_token(request):
+    """Check if auth token generation works"""
+
+    usr = User(request)
+    xmlrpc = XmlRpcBase(request)
+    token = xmlrpc._generate_auth_token(usr)
+
+    print "Token should be a string or unicode object and have langth of 32 chars!"
+    assert type(token) == str or type(token) == unicode
+    assert len(token) == 32
+
 
 coverage_modules = ['MoinMoin.xmlrpc']