I am having trouble stubbing out a celery task.
Here is the task itself:
@celery.task
def hello_task:
print("hello")
Here is my service calling the task:
class Hello:
def __init__(self, context: ContextObject):
self.context = context
def call_task(self) -> None:
hello_task.delay()
I am writing a test to test call_task in my Hello class:
@patch('path.to.hello_task')
def test_create_attestations(self, task_mock):
self.service.call_task()
task_mock.assert_called()
The problem that I have is that the @patch
statement is not stubbing out the call to hello_task so it is still printing hello. I want to stub out the celery task completely and just assert that it has been called.
Any tip?