Exemplo n.º 1
0
    def test_not_enough_calls(self):
        # need to drop down a level to bypass expected calls:
        r = Registry()
        fake = Fake()
        call_order = ExpectedCallOrder(fake)
        r.remember_expected_call_order(call_order)

        exp = ExpectedCall(fake, "callMe", call_order=call_order)
        call_order.add_expected_call(exp)

        r.verify()
Exemplo n.º 2
0
    def test_not_enough_calls(self):
        # need to drop down a level to bypass expected calls:
        r = Registry()
        fake = Fake()
        call_order = ExpectedCallOrder(fake)
        r.remember_expected_call_order(call_order)

        exp = ExpectedCall(fake, "callMe", call_order=call_order)
        call_order.add_expected_call(exp)

        r.verify()
    def test_verify_resets_call_order(self):
        exp_order = ExpectedCallOrder(self.fake)
        exp = ExpectedCall(self.fake, "callMe", call_order=exp_order)
        exp_order.add_expected_call(exp)
        self.reg.remember_expected_call_order(exp_order)

        exp()
        eq_(exp_order._actual_calls, [exp])

        self.reg.verify()
        eq_(exp_order._actual_calls, [], "call order calls were not reset by verify()")
Exemplo n.º 4
0
 def test_verify_resets_call_order(self):
     exp_order = ExpectedCallOrder(self.fake)
     exp = ExpectedCall(self.fake, 'callMe', call_order=exp_order)
     exp_order.add_expected_call(exp)
     self.reg.remember_expected_call_order(exp_order)
     
     exp()
     eq_(exp_order._actual_calls, [exp])
     
     self.reg.verify()
     eq_(exp_order._actual_calls, [], "call order calls were not reset by verify()")
Exemplo n.º 5
0
    def test_only_one_call(self):
        # need to drop down a level to bypass expected calls:
        r = Registry()
        fake = Fake()
        call_order = ExpectedCallOrder(fake)
        r.remember_expected_call_order(call_order)

        exp = ExpectedCall(fake, "one", call_order=call_order)
        call_order.add_expected_call(exp)
        exp() # call this

        exp = ExpectedCall(fake, "two", call_order=call_order)
        call_order.add_expected_call(exp)

        r.verify()
Exemplo n.º 6
0
 def registry(num):
     try:
         try:
             fudge.clear_calls()
             fudge.clear_expectations()
             
             exp_order = ExpectedCallOrder(self.fake)
             reg.remember_expected_call_order(exp_order)
             eq_(len(reg.get_expected_call_order().keys()), 1)
             
             # registered first time on __init__ :
             exp = ExpectedCall(self.fake, 'callMe', call_order=exp_order) 
             reg.expect_call(exp)
             reg.expect_call(exp)
             reg.expect_call(exp)
             eq_(len(reg.get_expected_calls()), 4)
             
             # actual calls:
             exp()
             exp()
             exp()
             exp()
             
             fudge.verify()
             fudge.clear_expectations()
         except Exception, er:
             thread_run.errors.append(er)
             raise
     finally:
         thread_run.waiting -= 1
Exemplo n.º 7
0
    def test_incremental_order_assertion_ok(self):
        # need to drop down a level to bypass expected calls:
        fake = Fake()
        call_order = ExpectedCallOrder(fake)

        exp = ExpectedCall(fake, "one", call_order=call_order)
        call_order.add_expected_call(exp)
        exp()  # call this

        exp = ExpectedCall(fake, "two", call_order=call_order)
        call_order.add_expected_call(exp)

        # two() not called but assertion is not finalized:
        call_order.assert_order_met(finalize=False)
Exemplo n.º 8
0
 def test_global_clear_expectations(self):
     exp = ExpectedCall(self.fake, 'callMe')
     exp()
     eq_(len(self.reg.get_expected_calls()), 1)
     exp_order = ExpectedCallOrder(self.fake)
     self.reg.remember_expected_call_order(exp_order)
     eq_(self.reg.get_expected_call_order().keys(), [self.fake])
     
     fudge.clear_expectations()
     
     eq_(len(self.reg.get_expected_calls()), 0, 
         "clear_expectations() should reset expectations")
     eq_(len(self.reg.get_expected_call_order().keys()), 0,
         "clear_expectations() should reset expected call order")
Exemplo n.º 9
0
    def test_incremental_order_assertion_ok(self):
        # need to drop down a level to bypass expected calls:
        fake = Fake()
        call_order = ExpectedCallOrder(fake)

        exp = ExpectedCall(fake, "one", call_order=call_order)
        call_order.add_expected_call(exp)
        exp() # call this

        exp = ExpectedCall(fake, "two", call_order=call_order)
        call_order.add_expected_call(exp)

        # two() not called but assertion is not finalized:
        call_order.assert_order_met(finalize=False)
Exemplo n.º 10
0
    def test_only_one_call(self):
        # need to drop down a level to bypass expected calls:
        r = Registry()
        fake = Fake()
        call_order = ExpectedCallOrder(fake)
        r.remember_expected_call_order(call_order)

        exp = ExpectedCall(fake, "one", call_order=call_order)
        call_order.add_expected_call(exp)
        exp()  # call this

        exp = ExpectedCall(fake, "two", call_order=call_order)
        call_order.add_expected_call(exp)

        r.verify()