class TestTupleModel(Model): partition = columns.UUID(primary_key=True, default=uuid4) int_tuple = columns.Tuple(columns.Integer, columns.Integer, columns.Integer, required=False) text_tuple = columns.Tuple(columns.Text, columns.Text, required=False) mixed_tuple = columns.Tuple(columns.Text, columns.Integer, columns.Text, required=False)
def test_instantiation_with_column_class(self): """ Tests that columns instantiated with a column class work properly and that the class is instantiated in the constructor @since 3.1 @jira_ticket PYTHON-478 @expected_result types are instantiated correctly @test_category object_mapper """ list_list = columns.List( columns.List(columns.Integer), required=False, ) map_list = columns.Map( columns.Text, columns.List(columns.Text), required=False, ) set_tuple = columns.Set( columns.Tuple(columns.Integer, columns.Integer), required=False, ) self.assertIsInstance(list_list, columns.List) self.assertIsInstance(list_list.types[0], columns.List) self.assertIsInstance(map_list.types[0], columns.Text) self.assertIsInstance(map_list.types[1], columns.List) self.assertIsInstance(set_tuple.types[0], columns.Tuple)
class TestNestedModel(Model): partition = columns.UUID(primary_key=True, default=uuid4) list_list = columns.List(columns.List(columns.Integer), required=False) map_list = columns.Map(columns.Text, columns.List(columns.Text), required=False) set_tuple = columns.Set(columns.Tuple(columns.Integer, columns.Integer), required=False)
def test_instantiation_with_column_class(self): """ Tests that columns instantiated with a column class work properly and that the class is instantiated in the constructor @since 3.1 @jira_ticket PYTHON-306 @expected_result types are instantiated correctly @test_category object_mapper """ mixed_tuple = columns.Tuple(columns.Text, columns.Integer, columns.Text, required=False) self.assertIsInstance(mixed_tuple.types[0], columns.Text) self.assertIsInstance(mixed_tuple.types[1], columns.Integer) self.assertIsInstance(mixed_tuple.types[2], columns.Text) self.assertEqual(len(mixed_tuple.types), 3)
class TestIndexSetModel(Model): partition = columns.UUID(primary_key=True) int_set = columns.Set(columns.Integer, index=True) int_list = columns.List(columns.Integer, index=True) text_map = columns.Map(columns.Text, columns.DateTime, index=True) mixed_tuple = columns.Tuple(columns.Text, columns.Integer, columns.Text, index=True)