cubicweb/server/test/unittest_migractions.py
changeset 11359 2da2dd60331c
parent 11292 ba81a528722b
child 11362 ebe75d73acdd
equal deleted inserted replaced
11358:179b5ff3f428 11359:2da2dd60331c
   184             fields = self.table_schema(mh, '%sNote' % SQL_PREFIX)
   184             fields = self.table_schema(mh, '%sNote' % SQL_PREFIX)
   185             self.assertEqual(fields['%sshortpara' % SQL_PREFIX], ('character varying', 64))
   185             self.assertEqual(fields['%sshortpara' % SQL_PREFIX], ('character varying', 64))
   186             # test default value set on existing entities
   186             # test default value set on existing entities
   187             self.assertEqual(cnx.execute('Note X').get_entity(0, 0).shortpara, 'hop')
   187             self.assertEqual(cnx.execute('Note X').get_entity(0, 0).shortpara, 'hop')
   188             # test default value set for next entities
   188             # test default value set for next entities
   189             self.assertEqual(cnx.create_entity('Note').shortpara, 'hop')
   189             self.assertEqual(cnx.create_entity('Note', shortpara=u'hophop').shortpara, u'hophop')
       
   190 
       
   191     def test_add_attribute_unique(self):
       
   192         with self.mh() as (cnx, mh):
       
   193             self.assertNotIn('unique_id', self.schema)
       
   194             mh.cmd_add_attribute('Note', 'unique_id')
       
   195             # test unique index creation
       
   196             dbh = self.repo.system_source.dbhelper
       
   197             self.assertTrue(dbh.index_exists(cnx.cnxset.cu, 'cw_Note', 'cw_unique_id', unique=True))
   190 
   198 
   191     def test_add_datetime_with_default_value_attribute(self):
   199     def test_add_datetime_with_default_value_attribute(self):
   192         with self.mh() as (cnx, mh):
   200         with self.mh() as (cnx, mh):
   193             self.assertNotIn('mydate', self.schema)
   201             self.assertNotIn('mydate', self.schema)
   194             self.assertNotIn('oldstyledefaultdate', self.schema)
   202             self.assertNotIn('oldstyledefaultdate', self.schema)