test/unittest_entity.py
branchstable
changeset 7677 134613d3b353
parent 7554 fdace9d67d96
child 7791 31bb51ea5485
equal deleted inserted replaced
7670:6397a9051f65 7677:134613d3b353
   570         # test explicit rest_attr
   570         # test explicit rest_attr
   571         person = req.create_entity('Personne', prenom=u'john', nom=u'doe')
   571         person = req.create_entity('Personne', prenom=u'john', nom=u'doe')
   572         self.assertEqual(person.rest_path(), 'personne/doe')
   572         self.assertEqual(person.rest_path(), 'personne/doe')
   573         # ambiguity test
   573         # ambiguity test
   574         person2 = req.create_entity('Personne', prenom=u'remi', nom=u'doe')
   574         person2 = req.create_entity('Personne', prenom=u'remi', nom=u'doe')
   575         person.clear_all_caches()
   575         person.cw_clear_all_caches()
   576         self.assertEqual(person.rest_path(), 'personne/eid/%s' % person.eid)
   576         self.assertEqual(person.rest_path(), 'personne/eid/%s' % person.eid)
   577         self.assertEqual(person2.rest_path(), 'personne/eid/%s' % person2.eid)
   577         self.assertEqual(person2.rest_path(), 'personne/eid/%s' % person2.eid)
   578         # unique attr with None value (wikiid in this case)
   578         # unique attr with None value (wikiid in this case)
   579         card1 = req.create_entity('Card', title=u'hop')
   579         card1 = req.create_entity('Card', title=u'hop')
   580         self.assertEqual(card1.rest_path(), 'card/eid/%s' % card1.eid)
   580         self.assertEqual(card1.rest_path(), 'card/eid/%s' % card1.eid)
   608 
   608 
   609     def test_metainformation_and_external_absolute_url(self):
   609     def test_metainformation_and_external_absolute_url(self):
   610         req = self.request()
   610         req = self.request()
   611         note = req.create_entity('Note', type=u'z')
   611         note = req.create_entity('Note', type=u'z')
   612         metainf = note.cw_metainformation()
   612         metainf = note.cw_metainformation()
   613         self.assertEqual(metainf, {'source': {'type': 'native', 'uri': 'system'}, 'type': u'Note', 'extid': None})
   613         self.assertEqual(metainf, {'source': {'type': 'native', 'uri': 'system',
       
   614                                               'use-cwuri-as-url': False},
       
   615                                    'type': u'Note', 'extid': None})
   614         self.assertEqual(note.absolute_url(), 'http://testing.fr/cubicweb/note/%s' % note.eid)
   616         self.assertEqual(note.absolute_url(), 'http://testing.fr/cubicweb/note/%s' % note.eid)
   615         metainf['source'] = metainf['source'].copy()
   617         metainf['source'] = metainf['source'].copy()
   616         metainf['source']['base-url']  = 'http://cubicweb2.com/'
   618         metainf['source']['base-url']  = 'http://cubicweb2.com/'
   617         metainf['extid']  = 1234
   619         metainf['extid']  = 1234
   618         self.assertEqual(note.absolute_url(), 'http://cubicweb2.com/note/1234')
   620         self.assertEqual(note.absolute_url(), 'http://cubicweb2.com/note/1234')