async def test_user_decorator(user, called, expected): cls = Mock() request = Mock() cls.user = user cls.func = CoroutineMock() cls.func = _add_user_header(cls.func) await cls.func(cls, request) assert request.add_header.called is called if request.add_header.call_args: assert isinstance(request.add_header.call_args[0][0], expected)
async def test_compress_decorator(compress, body, called, expected): cls = Mock() request = Mock() cls.compress = compress cls.body = body cls.func = CoroutineMock() cls.func = _add_compress_header(cls.func) await cls.func(cls, request) assert request.add_header.called is called if request.add_header.call_args: assert isinstance(request.add_header.call_args[0][0], expected)