示例#1
0
 def testTableInheritance(self):
     persons = Table(None, 'persons', Field('firstname', 'string'),
                     Field('lastname', 'string'))
     customers = Table(None, 'customers', Field('items_purchased',
                                                'integer'), persons)
     self.assert_(
         set(customers.fields).issuperset(
             set(['items_purchased', 'firstname', 'lastname'])))
示例#2
0
    def testTableAlias(self):
        db = DAL(DEFAULT_URI, check_reserved=["all"])
        persons = Table(db, "persons", Field("firstname", "string"), Field("lastname", "string"))
        aliens = persons.with_alias("aliens")

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#3
0
    def testTableAlias(self):
        db = DAL("sqlite:memory:")
        persons = Table(db, "persons", Field("firstname", "string"), Field("lastname", "string"))
        aliens = persons.with_alias("aliens")

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#4
0
    def testTableAlias(self):
        db = DAL('sqlite:memory:')
        persons = Table(db, 'persons', Field('firstname',
                           'string'), Field('lastname', 'string'))
        aliens = persons.with_alias('aliens')

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#5
0
    def testTableAlias(self):
        db = DAL(DEFAULT_URI, check_reserved=['all'])
        persons = Table(db, 'persons', Field('firstname',
                           'string'), Field('lastname', 'string'))
        aliens = persons.with_alias('aliens')

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#6
0
    def testTableAlias(self):
        db = DAL(DEFAULT_URI, check_reserved=['all'])
        persons = Table(db, 'persons', Field('firstname', 'string'),
                        Field('lastname', 'string'))
        aliens = persons.with_alias('aliens')

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#7
0
    def testTableAlias(self):
        db = DAL('sqlite:memory:')
        persons = Table(db, 'persons', Field('firstname',
                           'string'), Field('lastname', 'string'))
        aliens = persons.with_alias('aliens')

        # Are the different table instances with the same fields

        self.assert_(persons is not aliens)
        self.assert_(set(persons.fields) == set(aliens.fields))
示例#8
0
    def testFieldTypes(self):

        # Check that string, text, and password default length is 512
        for typ in ['string', 'password']:
            self.assert_(Field('abc', typ).length == 512,
                         "Default length for type '%s' is not 512 or 255" % typ)

        # Check that upload default length is 512
        self.assert_(Field('abc', 'upload').length == 512,
                     "Default length for type 'upload' is not 128")

        # Check that Tables passed in the type creates a reference
        self.assert_(Field('abc', Table(None, 'temp')).type
                      == 'reference temp',
                     'Passing an Table does not result in a reference type.')
示例#9
0
    def testTableCreation(self):

        # Check for error when not passing type other than Field or Table

        self.assertRaises(SyntaxError, Table, None, 'test', None)

        persons = Table(None, 'persons', Field('firstname', 'string'),
                        Field('lastname', 'string'))

        # Does it have the correct fields?

        self.assert_(
            set(persons.fields).issuperset(set(['firstname', 'lastname'])))

        # ALL is set correctly

        self.assert_('persons.firstname, persons.lastname' in str(persons.ALL))
示例#10
0
 def setUp(self):
     self.pt = Table(None, 'PseudoTable', Field('name'), Field('birthdate'))