Esempio n. 1
0
 def testRestCache_Override(self):
     m = mock.Mock()
     m.__name__ = 'mockMethod'
     m.return_value = 8
     wrapped = cache.rest_cache('key')(m)
     self.assertEqual(8, wrapped())
     self.assertEqual(8, wrapped())  # called twice for caching
     m2 = mock.Mock()
     m2.__name__ = 'mockMethod2'
     m2.return_value = 42
     wrapped2 = cache.rest_cache('key')(m2)  # same key
     self.assertEqual(8, wrapped2())
     m.assert_called_once()
     m2.assert_not_called()
Esempio n. 2
0
 def testRestCache_Override(self):
     m = mock.Mock()
     m.__name__ = 'mockMethod'
     m.return_value = 8
     wrapped = cache.rest_cache('key')(m)
     self.assertEqual(8, wrapped())
     self.assertEqual(8, wrapped())  # called twice for caching
     m2 = mock.Mock()
     m2.__name__ = 'mockMethod2'
     m2.return_value = 42
     wrapped2 = cache.rest_cache('key')(m2)  # same key
     self.assertEqual(8, wrapped2())
     m.assert_called_once()
     m2.assert_not_called()
Esempio n. 3
0
 def testRestCache_Basic(self):
     m = mock.Mock()
     m.__name__ = 'mockMethod'
     m.return_value = 5
     wrapped = cache.rest_cache(m)
     self.assertEqual(5, wrapped())
     self.assertEqual(5, wrapped())  # called twice for caching
     m.assert_called_once()
Esempio n. 4
0
 def testRestCache_Basic(self):
     m = mock.Mock()
     m.__name__ = 'mockMethod'
     m.return_value = 5
     wrapped = cache.rest_cache(m)
     self.assertEqual(5, wrapped())
     self.assertEqual(5, wrapped())  # called twice for caching
     m.assert_called_once()