Exemplo n.º 1
0
 def test_its_attribute(self):
     assert not hasattr(Predicate, '__nonzero__')
     # After booleanizing it:
     booleanize_predicates()
     assert hasattr(Predicate, '__nonzero__')
     # After debooleanizing it:
     debooleanize_predicates()
     assert not hasattr(Predicate, '__nonzero__')
Exemplo n.º 2
0
 def test_its_attribute(self):
     assert not hasattr(Predicate, '__nonzero__')
     # After booleanizing it:
     booleanize_predicates()
     assert hasattr(Predicate, '__nonzero__')
     # After debooleanizing it:
     debooleanize_predicates()
     assert not hasattr(Predicate, '__nonzero__')
Exemplo n.º 3
0
 def test_it(self):
     self.environ['pylons.routes_dict']['action'] = 'boolean_predicate'
     # Before booleanizing it, it's always true:
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is True' == resp.body, resp.body
     # ===== After booleanizing it:
     booleanize_predicates()
     # As anonymous
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is False' == resp.body, resp.body
     # As authenticated
     environ = {'REMOTE_USER': '******'}
     resp = self.app.get('/boolean_predicate', extra_environ=environ)
     assert 'The predicate is True' == resp.body, resp.body
     # ===== After debooleanizing it:
     debooleanize_predicates()
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is True' == resp.body, resp.body
Exemplo n.º 4
0
 def test_it(self):
     self.environ['pylons.routes_dict']['action'] = 'boolean_predicate'
     # Before booleanizing it, it's always true:
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is True' == resp.body, resp.body
     # ===== After booleanizing it:
     booleanize_predicates()
     # As anonymous
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is False' == resp.body, resp.body
     # As authenticated
     environ = {'REMOTE_USER': '******'}
     resp = self.app.get('/boolean_predicate', extra_environ=environ)
     assert 'The predicate is True' == resp.body, resp.body
     # ===== After debooleanizing it:
     debooleanize_predicates()
     resp = self.app.get('/boolean_predicate')
     assert 'The predicate is True' == resp.body, resp.body