MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_methods_etc

Method test_methods_etc

test/orm/test_scoping.py:138–174  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

136 assert s2.autoflush == False
137
138 def test_methods_etc(self):
139 mock_session = Mock()
140 mock_session.bind = "the bind"
141
142 sess = scoped_session(lambda: mock_session)
143
144 sess.add("add")
145 sess.delete("delete")
146
147 sess.get("Cls", 5)
148
149 eq_(sess.bind, "the bind")
150
151 eq_(
152 mock_session.mock_calls,
153 [
154 mock.call.add("add", _warn=True),
155 mock.call.delete("delete"),
156 mock.call.get(
157 "Cls",
158 5,
159 options=None,
160 populate_existing=None,
161 with_for_update=None,
162 identity_token=None,
163 execution_options=util.EMPTY_DICT,
164 bind_arguments=None,
165 ),
166 ],
167 )
168
169 with mock.patch(
170 "sqlalchemy.orm.session.object_session"
171 ) as mock_object_session:
172 sess.object_session("foo")
173
174 eq_(mock_object_session.mock_calls, [mock.call("foo")])
175
176 @testing.combinations(
177 "style1",

Callers

nothing calls this directly

Calls 6

scoped_sessionClass · 0.90
eq_Function · 0.90
addMethod · 0.45
deleteMethod · 0.45
getMethod · 0.45
object_sessionMethod · 0.45

Tested by

no test coverage detected