Mock Celery while testing, to prevent actual background task creation.
This commit is contained in:
parent
5af54237b9
commit
d0c30cfeca
@ -8,6 +8,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import typing
|
||||
import unittest.mock
|
||||
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
@ -58,6 +59,16 @@ class PillarTestServer(pillar.PillarServer):
|
||||
logging.getLogger('werkzeug').setLevel(logging.DEBUG)
|
||||
logging.getLogger('eve').setLevel(logging.DEBUG)
|
||||
|
||||
def _config_celery(self):
|
||||
"""Disables Celery by entirely mocking it.
|
||||
|
||||
Without this, actual Celery tasks will be created while the tests are running.
|
||||
"""
|
||||
|
||||
from celery import Celery
|
||||
|
||||
self.celery = unittest.mock.MagicMock(Celery)
|
||||
|
||||
|
||||
class AbstractPillarTest(TestMinimal):
|
||||
pillar_server_class = PillarTestServer
|
||||
|
Loading…
x
Reference in New Issue
Block a user