MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_refresh_arg_signature

Method test_refresh_arg_signature

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

Source from the content-addressed store, hash-verified

2687 self._test_class_guards(early, is_class=False)
2688
2689 def test_refresh_arg_signature(self):
2690 class Mapped:
2691 pass
2692
2693 self._map_it(Mapped)
2694
2695 m1 = Mapped()
2696 s = fixture_session()
2697
2698 with mock.patch.object(s, "_validate_persistent"):
2699 assert_raises_message(
2700 exc.ArgumentError,
2701 "with_for_update should be the boolean value True, "
2702 "or a dictionary with options",
2703 s.refresh,
2704 m1,
2705 with_for_update={},
2706 )
2707
2708 with mock.patch(
2709 "sqlalchemy.orm.session.loading._load_on_ident"
2710 ) as load_on_ident:
2711 s.refresh(m1, with_for_update={"read": True})
2712 s.refresh(m1, with_for_update=True)
2713 s.refresh(m1, with_for_update=False)
2714 s.refresh(m1)
2715
2716 from sqlalchemy.orm.query import ForUpdateArg
2717
2718 eq_(
2719 [
2720 call[-1]["with_for_update"]
2721 for call in load_on_ident.mock_calls
2722 ],
2723 [ForUpdateArg(read=True), ForUpdateArg(), None, None],
2724 )
2725
2726
2727class 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