MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_generative_cases

Method test_generative_cases

test/sql/test_insert_exec.py:3085–3192  ·  view source on GitHub ↗
(
        self,
        connection,
        metadata,
        sort_by_parameter_order,
        kind,
        operation,
        has_processor,
        freeze,
        driver_column_names,
    )

Source from the content-addressed store, hash-verified

3083 @testing.variation("freeze", [True, False])
3084 @testing.variation("driver_column_names", [True, False])
3085 def test_generative_cases(
3086 self,
3087 connection,
3088 metadata,
3089 sort_by_parameter_order,
3090 kind,
3091 operation,
3092 has_processor,
3093 freeze,
3094 driver_column_names,
3095 ):
3096 class MyInt(TypeDecorator):
3097 cache_ok = True
3098 impl = Integer
3099
3100 def result_processor(self, dialect, coltype):
3101 return str
3102
3103 class MyStr(TypeDecorator):
3104 cache_ok = True
3105 impl = String(42)
3106
3107 def result_processor(self, dialect, coltype):
3108 return str.upper
3109
3110 t1 = Table(
3111 "t1",
3112 metadata,
3113 Column(
3114 "id",
3115 MyInt() if has_processor else Integer(),
3116 primary_key=True,
3117 test_needs_autoincrement=True,
3118 ),
3119 Column("data", MyStr() if has_processor else String(42)),
3120 Column("w_d", String(42), server_default="foo"),
3121 )
3122
3123 stmt = t1.insert()
3124 data = [{"data": "a"}, {"data": "b"}, {"data": "c"}]
3125 if kind.returning:
3126 stmt = stmt.returning(
3127 t1.c.data,
3128 sort_by_parameter_order=bool(sort_by_parameter_order),
3129 )
3130 if has_processor:
3131 expected = [("A",), ("B",), ("C",)]
3132 else:
3133 expected = [("a",), ("b",), ("c",)]
3134 elif kind.returning_default:
3135 stmt = stmt.return_defaults(
3136 supplemental_cols=[t1.c.data],
3137 sort_by_parameter_order=bool(sort_by_parameter_order),
3138 )
3139 if has_processor:
3140 expected = [
3141 ("1", "A", "foo"),
3142 ("2", "B", "foo"),

Callers

nothing calls this directly

Calls 15

createMethod · 0.95
dropMethod · 0.95
TableClass · 0.90
ColumnClass · 0.90
IntegerClass · 0.90
StringClass · 0.90
eq_Function · 0.90
MyStrClass · 0.85
return_defaultsMethod · 0.80
_rewindMethod · 0.80
MyIntClass · 0.70
insertMethod · 0.45

Tested by

no test coverage detected