web/test/unittest_formfields.py
branchtls-sprint
changeset 1398 5fe84a5f7035
parent 1268 5db94912650b
child 1453 a9841184be7c
equal deleted inserted replaced
1397:6cbc7bc8ea6d 1398:5fe84a5f7035
     3 from logilab.common.testlib import TestCase, unittest_main
     3 from logilab.common.testlib import TestCase, unittest_main
     4 from cubicweb.devtools import TestServerConfiguration
     4 from cubicweb.devtools import TestServerConfiguration
     5 from cubicweb.web.formwidgets import PasswordInput
     5 from cubicweb.web.formwidgets import PasswordInput
     6 from cubicweb.web.formfields import *
     6 from cubicweb.web.formfields import *
     7 from cubicweb.entities.lib import Card
     7 from cubicweb.entities.lib import Card
     8 from cubicweb.entities.authobjs import EUser
     8 from cubicweb.entities.authobjs import CWUser
     9 from cubes.file.entities import File
     9 from cubes.file.entities import File
    10 
    10 
    11 config = TestServerConfiguration('data')
    11 config = TestServerConfiguration('data')
    12 config.bootstrap_cubes()
    12 config.bootstrap_cubes()
    13 schema = config.load_schema()
    13 schema = config.load_schema()
    14 Card.schema = schema
    14 Card.schema = schema
    15 Card.__initialize__()
    15 Card.__initialize__()
    16 EUser.schema = schema
    16 CWUser.schema = schema
    17 EUser.__initialize__()
    17 CWUser.__initialize__()
    18 File.schema = schema
    18 File.schema = schema
    19 File.__initialize__()
    19 File.__initialize__()
    20         
    20         
    21 class GuessFieldTC(TestCase):
    21 class GuessFieldTC(TestCase):
    22     
    22     
    47         self.assertIsInstance(wikiid_field, StringField)
    47         self.assertIsInstance(wikiid_field, StringField)
    48         self.assertEquals(wikiid_field.required, False)
    48         self.assertEquals(wikiid_field.required, False)
    49 
    49 
    50         
    50         
    51     def test_euser_fields(self):
    51     def test_euser_fields(self):
    52         upassword_field = guess_field(EUser, schema['upassword'])
    52         upassword_field = guess_field(CWUser, schema['upassword'])
    53         self.assertIsInstance(upassword_field, StringField)
    53         self.assertIsInstance(upassword_field, StringField)
    54         self.assertIsInstance(upassword_field.widget, PasswordInput)
    54         self.assertIsInstance(upassword_field.widget, PasswordInput)
    55         self.assertEquals(upassword_field.required, True)
    55         self.assertEquals(upassword_field.required, True)
    56 
    56 
    57         last_login_time_field = guess_field(EUser, schema['last_login_time'])
    57         last_login_time_field = guess_field(CWUser, schema['last_login_time'])
    58         self.assertIsInstance(last_login_time_field, DateTimeField)
    58         self.assertIsInstance(last_login_time_field, DateTimeField)
    59         self.assertEquals(last_login_time_field.required, False)
    59         self.assertEquals(last_login_time_field.required, False)
    60 
    60 
    61         in_group_field = guess_field(EUser, schema['in_group'])
    61         in_group_field = guess_field(CWUser, schema['in_group'])
    62         self.assertIsInstance(in_group_field, RelationField)
    62         self.assertIsInstance(in_group_field, RelationField)
    63         self.assertEquals(in_group_field.required, True)
    63         self.assertEquals(in_group_field.required, True)
    64         self.assertEquals(in_group_field.role, 'subject')
    64         self.assertEquals(in_group_field.role, 'subject')
    65         self.assertEquals(in_group_field.help, 'groups grant permissions to the user')
    65         self.assertEquals(in_group_field.help, 'groups grant permissions to the user')
    66 
    66 
    67         owned_by_field = guess_field(EUser, schema['owned_by'], 'object')
    67         owned_by_field = guess_field(CWUser, schema['owned_by'], 'object')
    68         self.assertIsInstance(owned_by_field, RelationField)
    68         self.assertIsInstance(owned_by_field, RelationField)
    69         self.assertEquals(owned_by_field.required, False)
    69         self.assertEquals(owned_by_field.required, False)
    70         self.assertEquals(owned_by_field.role, 'object')
    70         self.assertEquals(owned_by_field.role, 'object')
    71 
    71 
    72 
    72