示例#1
0
    def test_Table_droping(self):
        db.create_table('t', default_cols(a='text'))
        table = Table('t')

        table.drop()

        self.assertFalse(db.table_exists('t'))
示例#2
0
    def test_Table_drop_if_exist_drops_correctly(self):
        db.create_table('t', default_cols(a='text'))
        table = Table('t')

        table.drop_if_exists()

        self.assertFalse(db.table_exists('t'))
示例#3
0
    def test_existing_Table_adding_cols(self):
        t = Table('t')
        t.number = Integer()
        t.save()

        self.assertEqual(db.table_fields_types('t'), {
            'text': 'text',
            'number': 'integer'
        })
示例#4
0
    def test_new_Table_adding_cols_with_expression(self):
        with Table('t') as t:
            t.create_columns(name=Text(), number=Integer())

        self.assertTrue(db.table_exists('t'))
        self.assertEqual(db.table_fields_types('t'), {
            'name': 'text',
            'number': 'integer'
        })
示例#5
0
    def test_Table_renaming(self):
        db.create_table('t', default_cols(a='text'))

        table = Table('t')
        table.rename('s')
        table.save()

        self.assertFalse(db.table_exists('t'))
        self.assertTrue(db.table_exists('s'))
示例#6
0
    def test_new_Table_adding_cols(self):
        t = Table('t')
        t.create_columns(name=Text(), number=Integer())
        t.save()

        self.assertTrue(db.table_exists('t'))
        self.assertEqual(db.table_fields_types('t'), {
            'name': 'text',
            'number': 'integer'
        })
示例#7
0
    def test_Table_adding_cols_with_object_syntax(self):
        t = Table('t')
        t.text = Text()
        t.number = Integer()
        t.save()

        self.assertTrue(db.table_exists('t'))
        self.assertEqual(db.table_fields_types('t'), {
            'text': 'text',
            'number': 'integer'
        })
示例#8
0
    def test_Table_adding_foreing_constaints(self):
        with Table('s') as s:
            s.t = Integer()

        t = Table('t')
        t.text = Text()
        t.text.references = 's (t)'
        t.save()

        db.create('t', text='ay')

        self.assertTrue(db.table_exists('t'))
示例#9
0
 def test_Table_drop_if_exists_continues_if_table_not_exists(self):
     Table('t').drop_if_exists()
示例#10
0
 def test_dropping_all_cols_raise_valueError(self):
     t = Table('t')
     t.text.drop()
     self.assertRaises(ValueError, t.save)
示例#11
0
    def test_renaming_existing_col(self):
        t = Table('t')
        t.text.name = 'text2'
        t.save()

        self.assertEqual(db.table_fields_types('t'), {'text2': 'text'})
示例#12
0
    def setUpClass(cls):
        db.create_table('e', default_cols(a='integer', b='text'))

        cls.created_table = Table('c')
        cls.edited_table = Table('e')
示例#13
0
    def test_Table_making_cols_with_default(self):
        t = Table('t')
        t.text.null = False
        t.save()

        self.assertFalse(Table('t').text.null)
示例#14
0
 def test_Table_adding_cols_if_already_exists_raises_ColumnAlreadyExistsError(
         self):
     with self.assertRaises(ColumnAlreadyExistsError):
         Table('t').create_columns(text=Text())
示例#15
0
    def test_columns_of_created_table_are_accesible(self):
        t = Table('t')

        self.assertIsInstance(t.text, Text)
示例#16
0
    def setUp(self):
        db.drop_table('t')

        with Table('t') as t:
            t.text = Text()