MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_refresh_arg_signature

Method test_refresh_arg_signature

test/orm/test_session.py:2286–2321  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2284 self._test_class_guards(early, is_class=False)
2285
2286 def test_refresh_arg_signature(self):
2287 class Mapped:
2288 pass
2289
2290 self._map_it(Mapped)
2291
2292 m1 = Mapped()
2293 s = fixture_session()
2294
2295 with mock.patch.object(s, "_validate_persistent"):
2296 assert_raises_message(
2297 exc.ArgumentError,
2298 "with_for_update should be the boolean value True, "
2299 "or a dictionary with options",
2300 s.refresh,
2301 m1,
2302 with_for_update={},
2303 )
2304
2305 with mock.patch(
2306 "sqlalchemy.orm.session.loading.load_on_ident"
2307 ) as load_on_ident:
2308 s.refresh(m1, with_for_update={"read": True})
2309 s.refresh(m1, with_for_update=True)
2310 s.refresh(m1, with_for_update=False)
2311 s.refresh(m1)
2312
2313 from sqlalchemy.orm.query import ForUpdateArg
2314
2315 eq_(
2316 [
2317 call[-1]["with_for_update"]
2318 for call in load_on_ident.mock_calls
2319 ],
2320 [ForUpdateArg(read=True), ForUpdateArg(), None, None],
2321 )
2322
2323
2324class NewStyleExecutionTest(_fixtures.FixtureTest):

Callers

nothing calls this directly

Calls 8

_map_itMethod · 0.95
fixture_sessionFunction · 0.90
assert_raises_messageFunction · 0.90
eq_Function · 0.90
ForUpdateArgClass · 0.85
objectMethod · 0.80
MappedClass · 0.70
refreshMethod · 0.45

Tested by

no test coverage detected