web/test/unittest_views_basecontrollers.py
branchstable
changeset 9179 570208f74a84
parent 8941 7b26fe71404f
child 9184 b982e88e4836
equal deleted inserted replaced
9178:b5762ac9a82e 9179:570208f74a84
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
   168         self.assertEqual(path, 'cwuser/adim')
   168         self.assertEqual(path, 'cwuser/adim')
   169         e = self.execute('Any P WHERE P surname "Di Mascio"').get_entity(0, 0)
   169         e = self.execute('Any P WHERE P surname "Di Mascio"').get_entity(0, 0)
   170         self.assertEqual(e.surname, 'Di Mascio')
   170         self.assertEqual(e.surname, 'Di Mascio')
   171         email = e.use_email[0]
   171         email = e.use_email[0]
   172         self.assertEqual(email.address, 'dima@logilab.fr')
   172         self.assertEqual(email.address, 'dima@logilab.fr')
       
   173 
       
   174     def test_create_mandatory_inlined(self):
       
   175         req = self.request()
       
   176         req.form = {'eid': ['X', 'Y'], '__maineid' : 'X',
       
   177 
       
   178                     '__type:X': 'Salesterm',
       
   179                     '_cw_entity_fields:X': '',
       
   180 
       
   181                     '__type:Y': 'File',
       
   182                     '_cw_entity_fields:Y': 'data-subject,described_by_test-object',
       
   183                     'data-subject:Y': (u'coucou.txt', Binary('coucou')),
       
   184                     'described_by_test-object:Y': 'X',
       
   185                     }
       
   186         path, params = self.expect_redirect_handle_request(req, 'edit')
       
   187         self.assertTrue(path.startswith('salesterm/'), path)
       
   188         eid = path.split('/')[1]
       
   189         salesterm = req.entity_from_eid(eid)
       
   190         # The NOT NULL constraint of mandatory relation implies that the File
       
   191         # must be created before the Salesterm, otherwise Salesterm insertion
       
   192         # will fail.
       
   193         # NOTE: sqlite does have NOT NULL constraint, unlike Postgres so the
       
   194         # insertion does not fail and we have to check dumbly that File is
       
   195         # created before.
       
   196         self.assertGreater(salesterm.eid, salesterm.described_by_test[0].eid)
   173 
   197 
   174     def test_edit_multiple_linked(self):
   198     def test_edit_multiple_linked(self):
   175         req = self.request()
   199         req = self.request()
   176         peid = u(self.create_user(req, 'adim').eid)
   200         peid = u(self.create_user(req, 'adim').eid)
   177         req.form = {'eid': [peid, 'Y'], '__maineid': peid,
   201         req.form = {'eid': [peid, 'Y'], '__maineid': peid,