MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_disable_on_session

Method test_disable_on_session

test/ext/test_baked.py:513–551  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

511 eq_(bq(session).params(limit=limit, offset=offset).all(), exp)
512
513 def test_disable_on_session(self):
514 User = self.classes.User
515
516 canary = mock.Mock()
517
518 def fn1(s):
519 canary.fn1()
520 return s.query(User.id, User.name).order_by(User.id)
521
522 def fn2(q):
523 canary.fn2()
524 return q.filter(User.id == bindparam("id"))
525
526 def fn3(q):
527 canary.fn3()
528 return q
529
530 for x in range(3):
531 bq = self.bakery(fn1)
532
533 bq += fn2
534
535 sess = fixture_session(enable_baked_queries=False)
536 eq_(bq.add_criteria(fn3)(sess).params(id=7).all(), [(7, "jack")])
537
538 eq_(
539 canary.mock_calls,
540 [
541 mock.call.fn1(),
542 mock.call.fn2(),
543 mock.call.fn3(),
544 mock.call.fn1(),
545 mock.call.fn2(),
546 mock.call.fn3(),
547 mock.call.fn1(),
548 mock.call.fn2(),
549 mock.call.fn3(),
550 ],
551 )
552
553 def test_spoiled_full_w_params(self):
554 User = self.classes.User

Callers

nothing calls this directly

Calls 9

fixture_sessionFunction · 0.90
eq_Function · 0.90
bakeryMethod · 0.80
allMethod · 0.45
paramsMethod · 0.45
add_criteriaMethod · 0.45
fn1Method · 0.45
fn2Method · 0.45
fn3Method · 0.45

Tested by

no test coverage detected