'Test for inserting all protocol v4 column types into a UserType
test_can_insert_udts_protocol_v4_datatypes tests that each protocol v4 cqlengine column type can be inserted
into a UserType. It first creates a UserType that has each protocol v4 cqlengine column type, and a corresponding
table/Model. It then creates a UserType instance where all the fields have corresponding data, and inserts the
UserType as an instance of the Model. Finally, it verifies that each column read from the UserType from Cassandra
is the same as the input parameters.
@since 2.6.0
@jira_ticket PYTHON-245
@expected_result The UserType is inserted with each protocol v4 column type, and the resulting read yields proper data for each column.
@test_category data_types:udt'

def test_can_insert_udts_protocol_v4_datatypes(self):

    if (PROTOCOL_VERSION < 4):
        raise unittest.SkipTest('Protocol    v4    datatypes    in    UDTs    require    native    protocol    4+,    currently    using:    {0}'.format(PROTOCOL_VERSION))
    class Allv4Datatypes(UserType, ):
        a = columns.Date()
        b = columns.SmallInt()
        c = columns.Time()
        d = columns.TinyInt()
    class Allv4DatatypesModel(Model, ):
        id = columns.Integer(primary_key=True)
        data = columns.UserDefinedType(Allv4Datatypes)
    sync_table(Allv4DatatypesModel)
    self.addCleanup(drop_table, Allv4DatatypesModel)
    input = Allv4Datatypes(a=Date(date(1970, 1, 1)), b=32523, c=Time(time(16, 47, 25, 7)), d=123)
    Allv4DatatypesModel.create(id=0, data=input)
    self.assertEqual(1, Allv4DatatypesModel.objects.count())
    output = Allv4DatatypesModel.objects.first().data
    for i in range(ord('a'), (ord('a') + 3)):
        self.assertEqual(input[chr(i)], output[chr(i)])
