[Cubicweb] CubicWebTC / assertRaises / Unauthorized

Carlos Balderas carlos.balderas at gmail.com
Mon Aug 16 18:24:51 CEST 2010

Hi List!

I am working on unnitest for a cube, especially testing users permissions .

I want to test an 'Unauthorized' error using this:

# rql update sentence, this query must fail
rql = 'SET C description "description test" WHERE ....'

if I execute the rql as this:
rset = req.execute(rql)

When I run the test this is what I get:
Unauthorized: You are not allowed to perform update operation on ...

(so, the error shows as it should)

but exception does no raise if I use assertRaises method:

rql = 'SET C description "description test" WHERE ....'
self.assertRaises(Unauthorized, req.execute, rql)

this is what i get:
AssertionError: Unauthorized not raised

My first question

1.- what am I missing to make this exception raise and let it be caught by
assertRaises method?

2.- would this be a good method to test cubicweb users permissions or do you
recommend me another one for this purpose?

Thank you very much!
Carlos Balderas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20100816/3a0409e6/attachment-0186.html>

More information about the Cubicweb mailing list