--- a/server/test/data/migratedapp/schema.py Thu Jan 06 18:53:00 2011 +0100
+++ b/server/test/data/migratedapp/schema.py Fri Jan 07 08:13:43 2011 +0100
@@ -15,9 +15,7 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-"""
+"""cw.server.migraction test"""
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
SubjectRelation,
RichString, String, Int, Boolean, Datetime, Date)
@@ -68,7 +66,7 @@
type = String(maxsize=1)
unique_id = String(maxsize=1, required=True, unique=True)
mydate = Date(default='TODAY')
- shortpara = String(maxsize=64)
+ shortpara = String(maxsize=64, default='hop')
ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')])
attachment = SubjectRelation('File')
--- a/server/test/unittest_migractions.py Thu Jan 06 18:53:00 2011 +0100
+++ b/server/test/unittest_migractions.py Fri Jan 07 08:13:43 2011 +0100
@@ -108,6 +108,8 @@
self.mh.rollback()
def test_add_attribute_varchar(self):
+ self.request().create_entity('Note')
+ self.commit()
self.failIf('shortpara' in self.schema)
self.mh.cmd_add_attribute('Note', 'shortpara')
self.failUnless('shortpara' in self.schema)
@@ -117,6 +119,11 @@
notesql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' and name='%sNote'" % SQL_PREFIX)[0][0]
fields = dict(x.strip().split()[:2] for x in notesql.split('(', 1)[1].rsplit(')', 1)[0].split(','))
self.assertEqual(fields['%sshortpara' % SQL_PREFIX], 'varchar(64)')
+ req = self.request()
+ # test default value set on existing entities
+ self.assertEqual(req.execute('Note X').get_entity(0, 0).shortpara, 'hop')
+ # test default value set for next entities
+ self.assertEqual(req.create_entity('Note').shortpara, 'hop')
self.mh.rollback()
def test_add_datetime_with_default_value_attribute(self):