38 } |
38 } |
39 |
39 |
40 class EditControllerTC(CubicWebTC): |
40 class EditControllerTC(CubicWebTC): |
41 def setUp(self): |
41 def setUp(self): |
42 CubicWebTC.setUp(self) |
42 CubicWebTC.setUp(self) |
43 self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read')) |
43 self.assertTrue('users' in self.schema.eschema('CWGroup').get_groups('read')) |
44 |
44 |
45 def tearDown(self): |
45 def tearDown(self): |
46 CubicWebTC.tearDown(self) |
46 CubicWebTC.tearDown(self) |
47 self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read')) |
47 self.assertTrue('users' in self.schema.eschema('CWGroup').get_groups('read')) |
48 |
48 |
49 def test_noparam_edit(self): |
49 def test_noparam_edit(self): |
50 """check behaviour of this controller without any form parameter |
50 """check behaviour of this controller without any form parameter |
51 """ |
51 """ |
52 with self.assertRaises(ValidationError) as cm: |
52 with self.assertRaises(ValidationError) as cm: |
105 'upassword-subject-confirm:'+eid: 'tournicoton', |
105 'upassword-subject-confirm:'+eid: 'tournicoton', |
106 } |
106 } |
107 path, params = self.expect_redirect_publish(req, 'edit') |
107 path, params = self.expect_redirect_publish(req, 'edit') |
108 cnx.commit() # commit to check we don't get late validation error for instance |
108 cnx.commit() # commit to check we don't get late validation error for instance |
109 self.assertEqual(path, 'cwuser/user') |
109 self.assertEqual(path, 'cwuser/user') |
110 self.failIf('vid' in params) |
110 self.assertFalse('vid' in params) |
111 |
111 |
112 def test_user_editing_itself_no_relation(self): |
112 def test_user_editing_itself_no_relation(self): |
113 """checking we can edit an entity without specifying some required |
113 """checking we can edit an entity without specifying some required |
114 relations (meaning no changes) |
114 relations (meaning no changes) |
115 """ |
115 """ |
306 '__redirectparams': 'toto=tutu&tata=titi', |
306 '__redirectparams': 'toto=tutu&tata=titi', |
307 '__form_id': 'edition', |
307 '__form_id': 'edition', |
308 '__action_apply': '', |
308 '__action_apply': '', |
309 } |
309 } |
310 path, params = self.expect_redirect_publish(req, 'edit') |
310 path, params = self.expect_redirect_publish(req, 'edit') |
311 self.failUnless(path.startswith('blogentry/')) |
311 self.assertTrue(path.startswith('blogentry/')) |
312 eid = path.split('/')[1] |
312 eid = path.split('/')[1] |
313 self.assertEqual(params['vid'], 'edition') |
313 self.assertEqual(params['vid'], 'edition') |
314 self.assertNotEqual(int(eid), 4012) |
314 self.assertNotEqual(int(eid), 4012) |
315 self.assertEqual(params['__redirectrql'], redirectrql) |
315 self.assertEqual(params['__redirectrql'], redirectrql) |
316 self.assertEqual(params['__redirectvid'], 'primary') |
316 self.assertEqual(params['__redirectvid'], 'primary') |
440 'eid': 'A', '__maineid' : 'A', |
440 'eid': 'A', '__maineid' : 'A', |
441 '__type:A': 'BlogEntry', '_cw_entity_fields:A': 'title-subject,content-subject', |
441 '__type:A': 'BlogEntry', '_cw_entity_fields:A': 'title-subject,content-subject', |
442 'title-subject:A': u'"13:03:40"', |
442 'title-subject:A': u'"13:03:40"', |
443 'content-subject:A': u'"13:03:43"',} |
443 'content-subject:A': u'"13:03:43"',} |
444 path, params = self.expect_redirect_publish(req, 'edit') |
444 path, params = self.expect_redirect_publish(req, 'edit') |
445 self.failUnless(path.startswith('blogentry/')) |
445 self.assertTrue(path.startswith('blogentry/')) |
446 eid = path.split('/')[1] |
446 eid = path.split('/')[1] |
447 e = self.execute('Any C, T WHERE C eid %(x)s, C content T', {'x': eid}).get_entity(0, 0) |
447 e = self.execute('Any C, T WHERE C eid %(x)s, C content T', {'x': eid}).get_entity(0, 0) |
448 self.assertEqual(e.title, '"13:03:40"') |
448 self.assertEqual(e.title, '"13:03:40"') |
449 self.assertEqual(e.content, '"13:03:43"') |
449 self.assertEqual(e.content, '"13:03:43"') |
450 |
450 |
576 pageid='123', fname='view') |
576 pageid='123', fname='view') |
577 ctrl = self.ctrl(req) |
577 ctrl = self.ctrl(req) |
578 rset = self.john.as_rset() |
578 rset = self.john.as_rset() |
579 rset.req = req |
579 rset.req = req |
580 source = ctrl.publish() |
580 source = ctrl.publish() |
581 self.failUnless(source.startswith('<?xml version="1.0"?>\n' + STRICT_DOCTYPE + |
581 self.assertTrue(source.startswith('<?xml version="1.0"?>\n' + STRICT_DOCTYPE + |
582 u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">') |
582 u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">') |
583 ) |
583 ) |
584 req.xhtml_browser = lambda: False |
584 req.xhtml_browser = lambda: False |
585 source = ctrl.publish() |
585 source = ctrl.publish() |
586 self.failUnless(source.startswith('<div>')) |
586 self.assertTrue(source.startswith('<div>')) |
587 |
587 |
588 # def test_json_exec(self): |
588 # def test_json_exec(self): |
589 # rql = 'Any T,N WHERE T is Tag, T name N' |
589 # rql = 'Any T,N WHERE T is Tag, T name N' |
590 # ctrl = self.ctrl(self.request(mode='json', rql=rql, pageid='123')) |
590 # ctrl = self.ctrl(self.request(mode='json', rql=rql, pageid='123')) |
591 # self.assertEqual(ctrl.publish(), |
591 # self.assertEqual(ctrl.publish(), |