(
self,
connection,
optname,
value,
send_opts_how,
result_type,
close_result_when_finished,
)
| 2146 | "meth", "passed_in", "stmt", argnames="send_opts_how" |
| 2147 | ) |
| 2148 | def test_stream_options( |
| 2149 | self, |
| 2150 | connection, |
| 2151 | optname, |
| 2152 | value, |
| 2153 | send_opts_how, |
| 2154 | result_type, |
| 2155 | close_result_when_finished, |
| 2156 | ): |
| 2157 | table = self.tables.test |
| 2158 | |
| 2159 | connection.execute( |
| 2160 | table.insert(), |
| 2161 | [{"x": i, "y": "t_%d" % i} for i in range(15, 3000)], |
| 2162 | ) |
| 2163 | |
| 2164 | if optname == "stream_results": |
| 2165 | opts = {"stream_results": True, "max_row_buffer": value} |
| 2166 | elif optname == "yield_per": |
| 2167 | opts = {"yield_per": value} |
| 2168 | elif optname == "yield_per_meth": |
| 2169 | opts = {"stream_results": True} |
| 2170 | else: |
| 2171 | assert False |
| 2172 | |
| 2173 | if send_opts_how == "meth": |
| 2174 | result = connection.execution_options(**opts).execute( |
| 2175 | table.select() |
| 2176 | ) |
| 2177 | elif send_opts_how == "passed_in": |
| 2178 | result = connection.execute(table.select(), execution_options=opts) |
| 2179 | elif send_opts_how == "stmt": |
| 2180 | result = connection.execute( |
| 2181 | table.select().execution_options(**opts) |
| 2182 | ) |
| 2183 | else: |
| 2184 | assert False |
| 2185 | |
| 2186 | if result_type == "mapping": |
| 2187 | result = result.mappings() |
| 2188 | real_result = result._real_result |
| 2189 | elif result_type == "scalar": |
| 2190 | result = result.scalars() |
| 2191 | real_result = result._real_result |
| 2192 | else: |
| 2193 | real_result = result |
| 2194 | |
| 2195 | if optname == "yield_per_meth": |
| 2196 | result = result.yield_per(value) |
| 2197 | |
| 2198 | if result_type == "mapping" or result_type == "scalar": |
| 2199 | real_result = result._real_result |
| 2200 | else: |
| 2201 | real_result = result |
| 2202 | |
| 2203 | close_result_when_finished(result, consume=True) |
| 2204 | |
| 2205 | if optname == "yield_per" and value is not None: |
nothing calls this directly
no test coverage detected