(
self,
connection,
optname,
value,
send_opts_how,
result_type,
close_result_when_finished,
)
| 2059 | "meth", "passed_in", "stmt", argnames="send_opts_how" |
| 2060 | ) |
| 2061 | def test_stream_options( |
| 2062 | self, |
| 2063 | connection, |
| 2064 | optname, |
| 2065 | value, |
| 2066 | send_opts_how, |
| 2067 | result_type, |
| 2068 | close_result_when_finished, |
| 2069 | ): |
| 2070 | table = self.tables.test |
| 2071 | |
| 2072 | connection.execute( |
| 2073 | table.insert(), |
| 2074 | [{"x": i, "y": "t_%d" % i} for i in range(15, 3000)], |
| 2075 | ) |
| 2076 | |
| 2077 | if optname == "stream_results": |
| 2078 | opts = {"stream_results": True, "max_row_buffer": value} |
| 2079 | elif optname == "yield_per": |
| 2080 | opts = {"yield_per": value} |
| 2081 | elif optname == "yield_per_meth": |
| 2082 | opts = {"stream_results": True} |
| 2083 | else: |
| 2084 | assert False |
| 2085 | |
| 2086 | if send_opts_how == "meth": |
| 2087 | result = connection.execution_options(**opts).execute( |
| 2088 | table.select() |
| 2089 | ) |
| 2090 | elif send_opts_how == "passed_in": |
| 2091 | result = connection.execute(table.select(), execution_options=opts) |
| 2092 | elif send_opts_how == "stmt": |
| 2093 | result = connection.execute( |
| 2094 | table.select().execution_options(**opts) |
| 2095 | ) |
| 2096 | else: |
| 2097 | assert False |
| 2098 | |
| 2099 | if result_type == "mapping": |
| 2100 | result = result.mappings() |
| 2101 | real_result = result._real_result |
| 2102 | elif result_type == "scalar": |
| 2103 | result = result.scalars() |
| 2104 | real_result = result._real_result |
| 2105 | else: |
| 2106 | real_result = result |
| 2107 | |
| 2108 | if optname == "yield_per_meth": |
| 2109 | result = result.yield_per(value) |
| 2110 | |
| 2111 | if result_type == "mapping" or result_type == "scalar": |
| 2112 | real_result = result._real_result |
| 2113 | else: |
| 2114 | real_result = result |
| 2115 | |
| 2116 | close_result_when_finished(result, consume=True) |
| 2117 | |
| 2118 | if optname == "yield_per" and value is not None: |
nothing calls this directly
no test coverage detected