def test_perm_to_bool_lambda(self):
     x = [1,2]
     self.failUnless(_perm_to_bool(x,
                                   None,
                                   lambda z: len(z) == 2))
     x = [1,2]
     self.failIf(_perm_to_bool(x,
                               None,
                               lambda z: len(z) == 3))
    def test_perm_to_bool_method(self):
        class DummyModel(object):
            def a_permission(self):
                return True
        self.failUnless(_perm_to_bool(DummyModel(),
                                      None,
                                      'a_permission'))

        class DummyModel(object):
            def a_permission(self):
                return False
        self.failIf(_perm_to_bool(DummyModel(),
                                  None,
                                  'a_permission'))
 def test_perm_to_bool_attribute(self):
     x = Bunch(a_permission=True)
     self.failUnless(_perm_to_bool(x, object(), 'a_permission'))
     x = Bunch(a_permission=False)
     self.failIf(_perm_to_bool(x, object(), 'a_permission'))