MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_spoiled_half_w_params

Method test_spoiled_half_w_params

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

Source from the content-addressed store, hash-verified

594 )
595
596 def test_spoiled_half_w_params(self):
597 User = self.classes.User
598
599 canary = mock.Mock()
600
601 def fn1(s):
602 canary.fn1()
603 return s.query(User.id, User.name).order_by(User.id)
604
605 def fn2(q):
606 canary.fn2()
607 return q.filter(User.id == bindparam("id"))
608
609 def fn3(q):
610 canary.fn3()
611 return q
612
613 bq = self.bakery(fn1)
614
615 bq += fn2
616
617 for x in range(3):
618 bq = self.bakery(fn1)
619
620 bq += fn2
621
622 sess = fixture_session()
623 eq_(
624 bq.spoil().add_criteria(fn3)(sess).params(id=7).all(),
625 [(7, "jack")],
626 )
627
628 eq_(
629 canary.mock_calls,
630 [
631 mock.call.fn1(),
632 mock.call.fn2(),
633 mock.call.fn3(),
634 mock.call.fn3(),
635 mock.call.fn3(),
636 ],
637 )
638
639 def test_w_new_entities(self):
640 """Test that the query can have its entities modified in

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected