Ejemplo n.º 1
0
    def test_arguments_are_passed(self):
        old_func = Mock()
        new_func = api_operation(old_func)

        args = (Mock(), )
        kwargs = {"some_arg": Mock()}

        new_func(*args, **kwargs)
        old_func.assert_called_once_with(*args, **kwargs)
Ejemplo n.º 2
0
    def test_arguments_are_passed(self, r):
        old_func = Mock(return_value=1234)
        old_func.__name__ = "old_func"
        new_func = api_operation(old_func)

        args = (Mock(), )
        kwargs = {"some_arg": Mock()}

        new_func(*args, **kwargs)
        old_func.assert_called_once_with(*args, **kwargs)
Ejemplo n.º 3
0
 def test_return_value_is_passed(self, request):
     return_values = [
         1234,
         (None, 200),
         ("Value", 404),
         "<html/>",
     ]
     for return_value in return_values:
         with self.subTest(return_value=return_value):
             old_func = Mock(name="old_func", return_value=return_value)
             old_func.__name__ = "old_func"
             new_func = api_operation(old_func)
             self.assertEqual(old_func.return_value, new_func())
Ejemplo n.º 4
0
 def test_return_value_is_passed(self):
     old_func = Mock()
     old_func.__name__ = "old_func"
     new_func = api_operation(old_func)
     self.assertEqual(old_func.return_value, new_func())