class BackgroundProcess:
def background(f):
from functools import wraps
@wraps(f)
def wrapped(*args, **kwargs):
loop = asyncio.get_event_loop()
if callable(f):
return loop.run_in_executor(None, f, *args, **kwargs)
else:
raise TypeError('Task must be a callable')
return wrapped
class Monitoring
@BackgroundProcess.background
def post_monitoring_event_in_background()
return ''
How to write test cases for post_monitoring_event_in_background method by mocking @BackgroundProcess.background