equal
deleted
inserted
replaced
224 '__type:X': 'Salesterm', |
224 '__type:X': 'Salesterm', |
225 '_cw_entity_fields:X': '', |
225 '_cw_entity_fields:X': '', |
226 |
226 |
227 '__type:Y': 'File', |
227 '__type:Y': 'File', |
228 '_cw_entity_fields:Y': 'data-subject,described_by_test-object', |
228 '_cw_entity_fields:Y': 'data-subject,described_by_test-object', |
229 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
229 'data-subject:Y': (u'coucou.txt', Binary(b'coucou')), |
230 'described_by_test-object:Y': 'X', |
230 'described_by_test-object:Y': 'X', |
231 } |
231 } |
232 path, _params = self.expect_redirect_handle_request(req, 'edit') |
232 path, _params = self.expect_redirect_handle_request(req, 'edit') |
233 self.assertTrue(path.startswith('salesterm/'), path) |
233 self.assertTrue(path.startswith('salesterm/'), path) |
234 eid = path.split('/')[1] |
234 eid = path.split('/')[1] |
249 '_cw_entity_fields:X': 'described_by_test-subject', |
249 '_cw_entity_fields:X': 'described_by_test-subject', |
250 'described_by_test-subject:X': 'Y', |
250 'described_by_test-subject:X': 'Y', |
251 |
251 |
252 '__type:Y': 'File', |
252 '__type:Y': 'File', |
253 '_cw_entity_fields:Y': 'data-subject', |
253 '_cw_entity_fields:Y': 'data-subject', |
254 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
254 'data-subject:Y': (u'coucou.txt', Binary(b'coucou')), |
255 } |
255 } |
256 path, _params = self.expect_redirect_handle_request(req, 'edit') |
256 path, _params = self.expect_redirect_handle_request(req, 'edit') |
257 self.assertTrue(path.startswith('salesterm/'), path) |
257 self.assertTrue(path.startswith('salesterm/'), path) |
258 eid = path.split('/')[1] |
258 eid = path.split('/')[1] |
259 salesterm = req.entity_from_eid(eid) |
259 salesterm = req.entity_from_eid(eid) |
347 |
347 |
348 |
348 |
349 def test_interval_bound_constraint_success(self): |
349 def test_interval_bound_constraint_success(self): |
350 with self.admin_access.repo_cnx() as cnx: |
350 with self.admin_access.repo_cnx() as cnx: |
351 feid = cnx.execute('INSERT File X: X data_name "toto.txt", X data %(data)s', |
351 feid = cnx.execute('INSERT File X: X data_name "toto.txt", X data %(data)s', |
352 {'data': Binary('yo')})[0][0] |
352 {'data': Binary(b'yo')})[0][0] |
353 cnx.commit() |
353 cnx.commit() |
354 |
354 |
355 with self.admin_access.web_request(rollbackfirst=True) as req: |
355 with self.admin_access.web_request(rollbackfirst=True) as req: |
356 req.form = {'eid': ['X'], |
356 req.form = {'eid': ['X'], |
357 '__type:X': 'Salesterm', |
357 '__type:X': 'Salesterm', |
393 def test_interval_bound_constraint_validateform(self): |
393 def test_interval_bound_constraint_validateform(self): |
394 """Test the FormValidatorController controller on entity with |
394 """Test the FormValidatorController controller on entity with |
395 constrained attributes""" |
395 constrained attributes""" |
396 with self.admin_access.repo_cnx() as cnx: |
396 with self.admin_access.repo_cnx() as cnx: |
397 feid = cnx.execute('INSERT File X: X data_name "toto.txt", X data %(data)s', |
397 feid = cnx.execute('INSERT File X: X data_name "toto.txt", X data %(data)s', |
398 {'data': Binary('yo')})[0][0] |
398 {'data': Binary(b'yo')})[0][0] |
399 seid = cnx.create_entity('Salesterm', amount=0, described_by_test=feid).eid |
399 seid = cnx.create_entity('Salesterm', amount=0, described_by_test=feid).eid |
400 cnx.commit() |
400 cnx.commit() |
401 |
401 |
402 # ensure a value that violate a constraint is properly detected |
402 # ensure a value that violate a constraint is properly detected |
403 with self.admin_access.web_request(rollbackfirst=True) as req: |
403 with self.admin_access.web_request(rollbackfirst=True) as req: |
730 '_cw_entity_fields:X': 'described_by_test-subject', |
730 '_cw_entity_fields:X': 'described_by_test-subject', |
731 'described_by_test-subject:X': 'Y', |
731 'described_by_test-subject:X': 'Y', |
732 |
732 |
733 '__type:Y': 'File', |
733 '__type:Y': 'File', |
734 '_cw_entity_fields:Y': 'data-subject', |
734 '_cw_entity_fields:Y': 'data-subject', |
735 'data-subject:Y': (u'coucou.txt', Binary('coucou')), |
735 'data-subject:Y': (u'coucou.txt', Binary(b'coucou')), |
736 } |
736 } |
737 values_by_eid = dict((eid, req.extract_entity_params(eid, minparams=2)) |
737 values_by_eid = dict((eid, req.extract_entity_params(eid, minparams=2)) |
738 for eid in req.edited_eids()) |
738 for eid in req.edited_eids()) |
739 editctrl = self.vreg['controllers'].select('edit', req) |
739 editctrl = self.vreg['controllers'].select('edit', req) |
740 # don't call publish to enforce select order |
740 # don't call publish to enforce select order |