Adding the orphaned options pages to the navigation
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / mock_function_test.py
bloba2864ff7487629ce77c5b707f7775e191662208d
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import unittest
8 from mock_function import MockFunction
11 class MockFunctionUnittest(unittest.TestCase):
12 def testMockFunction(self):
13 @MockFunction
14 def calc(a, b, mult=1):
15 return (a + b) * mult
17 self.assertTrue(*calc.CheckAndReset(0))
18 self.assertEqual(
19 (False, 'calc: expected 1 call(s), got 0'), calc.CheckAndReset(1))
21 self.assertEqual(20, calc(2, 3, mult=4))
22 self.assertTrue(*calc.CheckAndReset(1))
23 self.assertTrue(*calc.CheckAndReset(0))
25 self.assertEqual(20, calc(2, 3, mult=4))
26 self.assertEqual(
27 (False, 'calc: expected 0 call(s), got 1'), calc.CheckAndReset(0))
29 self.assertEqual(3, calc(1, 2))
30 self.assertEqual(0, calc(3, 4, mult=0))
31 self.assertTrue(*calc.CheckAndReset(2))
32 self.assertTrue(*calc.CheckAndReset(0))
34 self.assertEqual(3, calc(1, 2))
35 self.assertEqual(0, calc(3, 4, mult=0))
36 self.assertEqual(
37 (False, 'calc: expected 3 call(s), got 2'), calc.CheckAndReset(3))
40 if __name__ == '__main__':
41 unittest.main()