182 |
182 |
183 '__type:Y': 'File', |
183 '__type:Y': 'File', |
184 '_cw_entity_fields:Y': 'data-subject,described_by_test-object', |
184 '_cw_entity_fields:Y': 'data-subject,described_by_test-object', |
185 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
185 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
186 'described_by_test-object:Y': 'X', |
186 'described_by_test-object:Y': 'X', |
|
187 } |
|
188 path, params = self.expect_redirect_handle_request(req, 'edit') |
|
189 self.assertTrue(path.startswith('salesterm/'), path) |
|
190 eid = path.split('/')[1] |
|
191 salesterm = req.entity_from_eid(eid) |
|
192 # The NOT NULL constraint of mandatory relation implies that the File |
|
193 # must be created before the Salesterm, otherwise Salesterm insertion |
|
194 # will fail. |
|
195 # NOTE: sqlite does have NOT NULL constraint, unlike Postgres so the |
|
196 # insertion does not fail and we have to check dumbly that File is |
|
197 # created before. |
|
198 self.assertGreater(salesterm.eid, salesterm.described_by_test[0].eid) |
|
199 |
|
200 def test_create_mandatory_inlined2(self): |
|
201 req = self.request() |
|
202 req.form = {'eid': ['X', 'Y'], '__maineid' : 'X', |
|
203 |
|
204 '__type:X': 'Salesterm', |
|
205 '_cw_entity_fields:X': 'described_by_test-subject', |
|
206 'described_by_test-subject:X': 'Y', |
|
207 |
|
208 '__type:Y': 'File', |
|
209 '_cw_entity_fields:Y': 'data-subject', |
|
210 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
187 } |
211 } |
188 path, params = self.expect_redirect_handle_request(req, 'edit') |
212 path, params = self.expect_redirect_handle_request(req, 'edit') |
189 self.assertTrue(path.startswith('salesterm/'), path) |
213 self.assertTrue(path.startswith('salesterm/'), path) |
190 eid = path.split('/')[1] |
214 eid = path.split('/')[1] |
191 salesterm = req.entity_from_eid(eid) |
215 salesterm = req.entity_from_eid(eid) |