# Path: arbalest/core.py
# class SchemaException(Exception):
#     pass
# 
# Path: arbalest/redshift/schema.py
# class Property(object):
#     def __init__(self, name, column_type_or_child_property, column_name=None):
#         self.name = name
#         self.keys = [name]
#         self.__column_name = column_name
#         self.__column_type_or_child_property = column_type_or_child_property
# 
#         if isinstance(column_type_or_child_property, basestring):
#             self.__validate_supported_type(column_type_or_child_property)
#             self.type = column_type_or_child_property
#             self.column_name = self.__name(column_name, name)
#         elif isinstance(column_type_or_child_property, Property):
#             child_column_name = column_name
#             child_property = column_type_or_child_property
# 
#             while isinstance(child_property, Property):
#                 self.keys.append(child_property.name)
#                 child_column_name = child_property.__column_name
#                 child_property = child_property.__column_type_or_child_property
# 
#             self.__validate_supported_type(child_property)
#             self.type = child_property
#             self.column_name = self.__name(child_column_name,
#                                            '_'.join(self.keys))
# 
#     @staticmethod
#     def __name(column_name, name):
#         return column_name if column_name is not None else name
# 
#     @staticmethod
#     def __validate_supported_type(column_type):
#         types = ['SMALLINT',
#                  'INT2',
#                  'INTEGER',
#                  'INT',
#                  'INT4',
#                  'BIGINT',
#                  'INT8',
#                  'DECIMAL',
#                  'NUMERIC',
#                  'REAL',
#                  'FLOAT4',
#                  'DOUBLE PRECISION',
#                  'FLOAT8',
#                  'FLOAT',
#                  'BOOLEAN',
#                  'BOOL',
#                  'CHAR',
#                  'CHARACTER',
#                  'NCHAR',
#                  'BPCHAR',
#                  'VARCHAR',
#                  'CHARACTER VARYING',
#                  'NVARCHAR',
#                  'TEXT',
#                  'DATE',
#                  'TIMESTAMP']
#         if True not in [type_name in str(column_type).upper() for type_name in
#                         types]:
#             raise SchemaException(
#                 'Invalid column type: {0}'.format(column_type))


import unittest
from arbalest.core import SchemaException
from arbalest.redshift.schema import Property


class PropertyShould(unittest.TestCase):
    def test_throw_schema_exception_when_adding_invalid_type(self):
        self.assertRaises(SchemaException, Property, 'property1', 'BLOB')

    def test_preserve_periods_for_default_column_name(self):
        self.assertEqual('some.column.name',
                         Property('some.column.name',
                                  'VARCHAR(MAX)').column_name)

    def test_have_column_name(self):
        self.assertEqual('my_column_name',

# Path: arbalest/core.py
# class SchemaException(Exception):
#     pass
# 
# Path: arbalest/redshift/schema.py
# class Property(object):
#     def __init__(self, name, column_type_or_child_property, column_name=None):
#         self.name = name
#         self.keys = [name]
#         self.__column_name = column_name
#         self.__column_type_or_child_property = column_type_or_child_property
# 
#         if isinstance(column_type_or_child_property, basestring):
#             self.__validate_supported_type(column_type_or_child_property)
#             self.type = column_type_or_child_property
#             self.column_name = self.__name(column_name, name)
#         elif isinstance(column_type_or_child_property, Property):
#             child_column_name = column_name
#             child_property = column_type_or_child_property
# 
#             while isinstance(child_property, Property):
#                 self.keys.append(child_property.name)
#                 child_column_name = child_property.__column_name
#                 child_property = child_property.__column_type_or_child_property
# 
#             self.__validate_supported_type(child_property)
#             self.type = child_property
#             self.column_name = self.__name(child_column_name,
#                                            '_'.join(self.keys))
# 
#     @staticmethod
#     def __name(column_name, name):
#         return column_name if column_name is not None else name
# 
#     @staticmethod
#     def __validate_supported_type(column_type):
#         types = ['SMALLINT',
#                  'INT2',
#                  'INTEGER',
#                  'INT',
#                  'INT4',
#                  'BIGINT',
#                  'INT8',
#                  'DECIMAL',
#                  'NUMERIC',
#                  'REAL',
#                  'FLOAT4',
#                  'DOUBLE PRECISION',
#                  'FLOAT8',
#                  'FLOAT',
#                  'BOOLEAN',
#                  'BOOL',
#                  'CHAR',
#                  'CHARACTER',
#                  'NCHAR',
#                  'BPCHAR',
#                  'VARCHAR',
#                  'CHARACTER VARYING',
#                  'NVARCHAR',
#                  'TEXT',
#                  'DATE',
#                  'TIMESTAMP']
#         if True not in [type_name in str(column_type).upper() for type_name in
#                         types]:
#             raise SchemaException(
#                 'Invalid column type: {0}'.format(column_type))


# Path: test/redshift/test_property.py
import unittest
from arbalest.core import SchemaException
from arbalest.redshift.schema import Property



class PropertyShould(unittest.TestCase):
    def test_throw_schema_exception_when_adding_invalid_type(self):
        self.assertRaises(SchemaException, Property, 'property1', 'BLOB')

    def test_preserve_periods_for_default_column_name(self):
        self.assertEqual('some.column.name',
                         Property('some.column.name',
                                  'VARCHAR(MAX)').column_name)

    def test_have_column_name(self):
        self.assertEqual('my_column_name',

                         Property('some.column.name', 'VARCHAR(MAX)',