comparison test/test_xmlrpc.py @ 5376:64b05e24dbd8

Python 3 preparation: convert print to a function. Tool-assisted patch. It is possible that some "from __future__ import print_function" are not in fact needed, if a file only uses print() with a single string as an argument and so would work fine in Python 2 without that import.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 09:54:52 +0000
parents 198b6e810c67
children e9fb7c539a52
comparison
equal deleted inserted replaced
5375:1ad46057ae4a 5376:64b05e24dbd8
2 # Copyright (C) 2007 Stefan Seefeld 2 # Copyright (C) 2007 Stefan Seefeld
3 # All rights reserved. 3 # All rights reserved.
4 # For license terms see the file COPYING.txt. 4 # For license terms see the file COPYING.txt.
5 # 5 #
6 6
7 from __future__ import print_function
7 import unittest, os, shutil, errno, sys, difflib, cgi, re 8 import unittest, os, shutil, errno, sys, difflib, cgi, re
8 9
9 from xmlrpclib import MultiCall 10 from xmlrpclib import MultiCall
10 from roundup.cgi.exceptions import * 11 from roundup.cgi.exceptions import *
11 from roundup import init, instance, password, hyperdb, date 12 from roundup import init, instance, password, hyperdb, date
29 self.instance = db_test_base.setupTracker(self.dirname, self.backend) 30 self.instance = db_test_base.setupTracker(self.dirname, self.backend)
30 31
31 # open the database 32 # open the database
32 self.db = self.instance.open('admin') 33 self.db = self.instance.open('admin')
33 34
34 print "props_only default", self.db.security.get_props_only_default() 35 print("props_only default", self.db.security.get_props_only_default())
35 36
36 # Get user id (user4 maybe). Used later to get data from db. 37 # Get user id (user4 maybe). Used later to get data from db.
37 self.joeid = 'user' + self.db.user.create(username='joe', 38 self.joeid = 'user' + self.db.user.create(username='joe',
38 password=password.Password('random'), address='random@home.org', 39 password=password.Password('random'), address='random@home.org',
39 realname='Joe Random', roles='User') 40 realname='Joe Random', roles='User')
161 self.assertEqual(users_before, users_after) 162 self.assertEqual(users_before, users_after)
162 163
163 # test a bogus action 164 # test a bogus action
164 with self.assertRaises(Exception) as cm: 165 with self.assertRaises(Exception) as cm:
165 self.server.action('bogus') 166 self.server.action('bogus')
166 print cm.exception 167 print(cm.exception)
167 self.assertEqual(cm.exception.message, 168 self.assertEqual(cm.exception.message,
168 'action "bogus" is not supported ') 169 'action "bogus" is not supported ')
169 170
170 def testAuthDeniedEdit(self): 171 def testAuthDeniedEdit(self):
171 # Wrong permissions (caught by roundup security module). 172 # Wrong permissions (caught by roundup security module).
204 self.db.security.addRole(name='Project') 205 self.db.security.addRole(name='Project')
205 self.db.security.addPermissionToRole('User', 'Web Access') 206 self.db.security.addPermissionToRole('User', 'Web Access')
206 self.db.security.addPermissionToRole('Project', 'Web Access') 207 self.db.security.addPermissionToRole('Project', 'Web Access')
207 # Allow viewing keyword 208 # Allow viewing keyword
208 p = self.db.security.addPermission(name='View', klass='keyword') 209 p = self.db.security.addPermission(name='View', klass='keyword')
209 print "View keyword class: %r"%p 210 print("View keyword class: %r"%p)
210 self.db.security.addPermissionToRole('User', p) 211 self.db.security.addPermissionToRole('User', p)
211 # Allow viewing interesting things (but not keyword) on issue 212 # Allow viewing interesting things (but not keyword) on issue
212 # But users might only view issues where they are on nosy 213 # But users might only view issues where they are on nosy
213 # (so in the real world the check method would be better) 214 # (so in the real world the check method would be better)
214 p = self.db.security.addPermission(name='View', klass='issue', 215 p = self.db.security.addPermission(name='View', klass='issue',
215 properties=("title", "status"), check=lambda x,y,z: True) 216 properties=("title", "status"), check=lambda x,y,z: True)
216 print "View keyword class w/ props: %r"%p 217 print("View keyword class w/ props: %r"%p)
217 self.db.security.addPermissionToRole('User', p) 218 self.db.security.addPermissionToRole('User', p)
218 # Allow role "Project" access to whole issue 219 # Allow role "Project" access to whole issue
219 p = self.db.security.addPermission(name='View', klass='issue') 220 p = self.db.security.addPermission(name='View', klass='issue')
220 self.db.security.addPermissionToRole('Project', p) 221 self.db.security.addPermissionToRole('Project', p)
221 # Allow all access to status: 222 # Allow all access to status:
240 241
241 # Conditionally allow view of whole issue (check is False here, 242 # Conditionally allow view of whole issue (check is False here,
242 # this might check for keyword owner in the real world) 243 # this might check for keyword owner in the real world)
243 p = self.db.security.addPermission(name='View', klass='issue', 244 p = self.db.security.addPermission(name='View', klass='issue',
244 check=lambda x,y,z: False) 245 check=lambda x,y,z: False)
245 print "View issue class: %r"%p 246 print("View issue class: %r"%p)
246 self.db.security.addPermissionToRole('User', p) 247 self.db.security.addPermissionToRole('User', p)
247 # Allow user to search for issue.status 248 # Allow user to search for issue.status
248 p = self.db.security.addPermission(name='Search', klass='issue', 249 p = self.db.security.addPermission(name='Search', klass='issue',
249 properties=("status",)) 250 properties=("status",))
250 print "View Search class w/ props: %r"%p 251 print("View Search class w/ props: %r"%p)
251 self.db.security.addPermissionToRole('User', p) 252 self.db.security.addPermissionToRole('User', p)
252 253
253 keyw = {'keyword':self.db.keyword.lookup('d1')} 254 keyw = {'keyword':self.db.keyword.lookup('d1')}
254 stat = {'status':self.db.status.lookup('open')} 255 stat = {'status':self.db.status.lookup('open')}
255 keygroup = keysort = [('+', 'keyword')] 256 keygroup = keysort = [('+', 'keyword')]

Roundup Issue Tracker: http://roundup-tracker.org/