Merge with 3.26
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 05 Apr 2019 17:21:14 +0200
changeset 12566 6b3523f81f42
parent 12557 dc04947379b5 (current diff)
parent 12564 83888a8d6083 (diff)
child 12567 26744ad37953
Merge with 3.26
cubicweb/pyramid/config.py
cubicweb/rset.py
cubicweb/test/unittest_rset.py
requirements/test-misc.txt
requirements/test-server.txt
--- a/.hgtags	Thu Mar 28 11:15:28 2019 +0100
+++ b/.hgtags	Fri Apr 05 17:21:14 2019 +0200
@@ -632,3 +632,4 @@
 8362503a92482e74a674c78fe009cf6ff346c817 debian/3.26.6-1
 ee4ad63c91e5406e29f079f1f2d3774361798ac8 3.26.7
 91f75319a726b523a09103540d3bc6872aaf2ae4 3.26.8
+4d6909de765ac036ddef00b5853213fcae56d525 3.26.9
--- a/cubicweb/pyramid/config.py	Thu Mar 28 11:15:28 2019 +0100
+++ b/cubicweb/pyramid/config.py	Fri Apr 05 17:21:14 2019 +0200
@@ -32,7 +32,9 @@
 def get_random_secret_key():
     """Return 50-character secret string"""
     chars = string.ascii_letters + string.digits
-    return "".join([random.choice(chars) for i in range(50)])
+    secure_random = random.SystemRandom()
+
+    return "".join([secure_random.choice(chars) for i in range(50)])
 
 
 class CubicWebPyramidConfiguration(BaseWebConfiguration, ServerConfiguration):
--- a/cubicweb/pyramid/test/test_config.py	Thu Mar 28 11:15:28 2019 +0100
+++ b/cubicweb/pyramid/test/test_config.py	Fri Apr 05 17:21:14 2019 +0200
@@ -31,7 +31,7 @@
 class PyramidConfigTC(TestCase):
 
     def test_get_random_secret_key(self):
-        with patch('random.choice', return_value='0') as patched_choice:
+        with patch('random.SystemRandom.choice', return_value='0') as patched_choice:
             secret = config.get_random_secret_key()
         self.assertEqual(patched_choice.call_count, 50)
         self.assertEqual(secret, '0' * 50)
@@ -43,7 +43,7 @@
             os.environ['CW_INSTANCES_DIR'] = instancedir
             try:
                 cfg = config.CubicWebPyramidConfiguration(appid)
-                with patch('random.choice', return_value='0') as patched_choice:
+                with patch('random.SystemRandom.choice', return_value='0') as patched_choice:
                     cfg.write_development_ini(['foo', 'bar'])
             finally:
                 os.environ.pop('CW_INSTANCES_DIR')
--- a/cubicweb/rset.py	Thu Mar 28 11:15:28 2019 +0100
+++ b/cubicweb/rset.py	Fri Apr 05 17:21:14 2019 +0200
@@ -94,6 +94,11 @@
         """Return possible actions on this result set. Should always be called with the same
         arguments so it may be computed only once.
         """
+        if not kwargs:
+            raise ValueError("ResultSet.possible_actions is expecting to receive "
+                             "keywords arguments to be able to compute access to "
+                             "the cache only once but you provided none.")
+
         key = tuple(sorted(kwargs.items()))
         if self._actions_cache is None:
             actions = self.req.vreg['actions'].poss_visible_objects(
@@ -101,9 +106,12 @@
             self._actions_cache = (key, actions)
             return actions
         else:
-            assert key == self._actions_cache[0], \
-                'unexpected new arguments for possible actions (%s vs %s)' % (
-                    key, self._actions_cache[0])
+            if key != self._actions_cache[0]:
+                raise ValueError("ResultSet.possible_actions expects to always "
+                                 "receive the same arguments to compute the "
+                                 "cache once, but you've call it with the "
+                                 "arguments: '%s' that aren't the same as the "
+                                 "previously used combinaison '%s'" % (key, self._actions_cache[0]))
             return self._actions_cache[1]
 
     def __len__(self):
--- a/cubicweb/test/unittest_rset.py	Thu Mar 28 11:15:28 2019 +0100
+++ b/cubicweb/test/unittest_rset.py	Fri Apr 05 17:21:14 2019 +0200
@@ -643,8 +643,8 @@
         with self.admin_access.web_request() as req:
             rset = req.execute('Any D, COUNT(U) GROUPBY D WHERE U is CWUser, U creation_date D')
             rset.possible_actions(argument='Value')
-            self.assertRaises(AssertionError, rset.possible_actions, argument='OtherValue')
-            self.assertRaises(AssertionError, rset.possible_actions, other_argument='Value')
+            self.assertRaises(ValueError, rset.possible_actions, argument='OtherValue')
+            self.assertRaises(ValueError, rset.possible_actions, other_argument='Value')
 
     def test_count_users_by_date(self):
         with self.admin_access.web_request() as req:
--- a/requirements/test-misc.txt	Thu Mar 28 11:15:28 2019 +0100
+++ b/requirements/test-misc.txt	Fri Apr 05 17:21:14 2019 +0200
@@ -13,7 +13,7 @@
 flake8
 
 ## cubicweb/hooks/test
-psycopg2
+psycopg2-binary
 
 ## cubicweb/pyramid/test
 pyramid >= 1.5.0
--- a/requirements/test-server.txt	Thu Mar 28 11:15:28 2019 +0100
+++ b/requirements/test-server.txt	Fri Apr 05 17:21:14 2019 +0200
@@ -1,3 +1,3 @@
 mock
-psycopg2
+psycopg2-binary
 ldap3 < 2