def test_string_text_type_exceptions(self): for type_id in [_MySQLStringColumn.TYPE_TINYTEXT, _MySQLStringColumn.TYPE_MEDIUMTEXT, _MySQLStringColumn.TYPE_LONGTEXT]: try: _MySQLStringColumn('abc').text_type(type_id, 15) self.fail('Was able to specify length even though it is not ' + 'allowed for a non-text column.') except TableBuilderException as e: self.assertEqual( 'you can only specify the length if the column is text', e.get_message())
def test_string_text_type_exceptions(self): for type_id in [_MySQLStringColumn.TYPE_TINYTEXT, _MySQLStringColumn.TYPE_MEDIUMTEXT, _MySQLStringColumn.TYPE_LONGTEXT]: try: _MySQLStringColumn('abc').text_type(type_id, 15) self.fail('Was able to specify length even though it is not ' + 'allowed for a non-text column.') except TableBuilderException as e: self.assertEqual( 'you can only specify the length if the column is text', e.get_message())
def test_string_list_set(self): self.assertEqual( "abc set('x', 'y') character set def collate ghi default null", _MySQLStringColumn('abc') .list_type(_MySQLStringColumn.TYPE_SET, ['x', 'y']) .charset('def') .collation('ghi') .get_definition())
def test_string_char_varchar(self): self.assertEqual( "abc varchar(15) character set def collate ghi default null", _MySQLStringColumn('abc') .char_type(_MySQLStringColumn.TYPE_VARCHAR, 15) .charset('def') .collation('ghi') .get_definition())
def test_string_blob_longblob(self): self.assertEqual( "abc longblob default null", _MySQLStringColumn('abc') .binary_type(_MySQLStringColumn.TYPE_LONGBLOB) .charset('def') .collation('ghi') .get_definition())
def test_string_binary_varbinary(self): self.assertEqual( "abc varbinary(15) character set def collate ghi default null", _MySQLStringColumn('abc') .binary_type(_MySQLStringColumn.TYPE_VARBINARY, 15) .charset('def') .collation('ghi') .get_definition())
def test_string_list_set(self): self.assertEqual( "abc set('x', 'y') character set def collate ghi default null", _MySQLStringColumn('abc') .list_type(_MySQLStringColumn.TYPE_SET, ['x', 'y']) .charset('def') .collation('ghi') .get_definition())
def test_string_char_varchar(self): self.assertEqual( "abc varchar(15) character set def collate ghi default null", _MySQLStringColumn('abc') .char_type(_MySQLStringColumn.TYPE_VARCHAR, 15) .charset('def') .collation('ghi') .get_definition())
def test_string_blob_longblob(self): self.assertEqual( "abc longblob default null", _MySQLStringColumn('abc') .binary_type(_MySQLStringColumn.TYPE_LONGBLOB) .charset('def') .collation('ghi') .get_definition())
def test_string_binary_varbinary(self): self.assertEqual( "abc varbinary(15) default null", _MySQLStringColumn('abc') .binary_type(_MySQLStringColumn.TYPE_VARBINARY, 15) .charset('def') .collation('ghi') .get_definition())
def test_string_validate_type_id_exceptions(self): try: _MySQLStringColumn('abc').binary_type(-1) self.fail('Was able to set binary type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').blob_type(-1) self.fail('Was able to set blob type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').char_type(-1) self.fail('Was able to set char type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').list_type(-1) self.fail('Was able to set list type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').text_type(-1) self.fail('Was able to set text type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message())
def test_string_validate_type_id_exceptions(self): try: _MySQLStringColumn('abc').binary_type(-1) self.fail('Was able to set binary type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').blob_type(-1) self.fail('Was able to set blob type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').char_type(-1) self.fail('Was able to set char type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').list_type(-1) self.fail('Was able to set list type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message()) try: _MySQLStringColumn('abc').text_type(-1) self.fail('Was able to set text type even though the ID provided ' + 'was invalid.') except TableBuilderException as e: self.assertEqual('the type ID provided was invalid', e.get_message())
def test_text_type_with_no_length(self): self.assertEqual( 'abc text character set utf8 collate utf8_unicode_ci default null', _MySQLStringColumn('abc') .text_type(_MySQLStringColumn.TYPE_TEXT) .get_definition())
def test_text_type_with_no_length(self): self.assertEqual( 'abc text character set utf8 collate utf8_unicode_ci default null', _MySQLStringColumn('abc') .text_type(_MySQLStringColumn.TYPE_TEXT) .get_definition())