Fix flaky test due to different behaviors between cubicweb versions 3.26.14 and 3.26.17
authorLaurent Wouters <lwouters@cenotelie.fr>
Wed, 29 Apr 2020 15:22:49 +0200
changeset 17 b792134b6f43
parent 16 bc001415dcbe
child 18 3d0d6edadf69
Fix flaky test due to different behaviors between cubicweb versions 3.26.14 and 3.26.17
test/test_graphql.py
--- a/test/test_graphql.py	Wed Apr 29 15:22:11 2020 +0200
+++ b/test/test_graphql.py	Wed Apr 29 15:22:49 2020 +0200
@@ -105,8 +105,13 @@
                 self.assertEqual(len(result.data["Affaire"]), 1)
             with self.new_access(u'anon').repo_cnx() as cnx:
                 # Reading is not OK for anonymous
-                result = self.gql_ok(cnx, query, sujet="cool")
-                self.assertEqual(len(result.data["Affaire"]), 0)
+                result = GraphQLQuerier.execute(cnx, query, sujet="cool")
+                if result.errors is not None and len(result.errors) >= 1:
+                    # there was an error
+                    self.assertIsNone(result.data["Affaire"])
+                else:
+                    # no error, result must be empty
+                    self.assertEqual(len(result.data["Affaire"]), 0)
 
     def test_upassword_not_selectable(self):
         query = "{ CWUser { login, upassword } }"