1 # -*- coding: iso-8859-1 -*- |
1 # -*- coding: iso-8859-1 -*- |
2 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
4 # |
4 # |
5 # This file is part of CubicWeb. |
5 # This file is part of CubicWeb. |
6 # |
6 # |
7 # CubicWeb is free software: you can redistribute it and/or modify it under the |
7 # CubicWeb is free software: you can redistribute it and/or modify it under the |
1266 beid = self.execute("INSERT Bookmark Y: Y title 'toto', Y path '/view'")[0][0] |
1266 beid = self.execute("INSERT Bookmark Y: Y title 'toto', Y path '/view'")[0][0] |
1267 self.execute('SET X title XN + %(suffix)s WHERE X is Bookmark, X title XN', {'suffix': u'-moved'}) |
1267 self.execute('SET X title XN + %(suffix)s WHERE X is Bookmark, X title XN', {'suffix': u'-moved'}) |
1268 newname = self.execute('Any XN WHERE X eid %(x)s, X title XN', {'x': beid})[0][0] |
1268 newname = self.execute('Any XN WHERE X eid %(x)s, X title XN', {'x': beid})[0][0] |
1269 self.assertEqual(newname, 'toto-moved') |
1269 self.assertEqual(newname, 'toto-moved') |
1270 |
1270 |
|
1271 def test_update_not_exists(self): |
|
1272 rset = self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto'") |
|
1273 eid1, eid2 = rset[0][0], rset[0][1] |
|
1274 rset = self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s, " |
|
1275 "NOT EXISTS(Z ecrit_par X)", |
|
1276 {'x': unicode(eid1), 'y': unicode(eid2)}) |
|
1277 self.assertEqual(tuplify(rset.rows), [(eid1, eid2)]) |
|
1278 |
1271 def test_update_query_error(self): |
1279 def test_update_query_error(self): |
1272 self.execute("INSERT Personne Y: Y nom 'toto'") |
1280 self.execute("INSERT Personne Y: Y nom 'toto'") |
1273 self.assertRaises(Exception, self.execute, "SET X nom 'toto', X is Personne") |
1281 self.assertRaises(Exception, self.execute, "SET X nom 'toto', X is Personne") |
1274 self.assertRaises(QueryError, self.execute, "SET X nom 'toto', X has_text 'tutu' WHERE X is Personne") |
1282 self.assertRaises(QueryError, self.execute, "SET X nom 'toto', X has_text 'tutu' WHERE X is Personne") |
1275 self.assertRaises(QueryError, self.execute, "SET X login 'tutu', X eid %s" % cnx.user(self.session).eid) |
1283 self.assertRaises(QueryError, self.execute, "SET X login 'tutu', X eid %s" % cnx.user(self.session).eid) |
|
1284 |
1276 |
1285 |
1277 # HAVING on write queries test ############################################# |
1286 # HAVING on write queries test ############################################# |
1278 |
1287 |
1279 def test_update_having(self): |
1288 def test_update_having(self): |
1280 peid1 = self.execute("INSERT Personne Y: Y nom 'hop', Y tel 1")[0][0] |
1289 peid1 = self.execute("INSERT Personne Y: Y nom 'hop', Y tel 1")[0][0] |