cic-internal-integration/apps/cic-eth/tests/fixtures_celery.py

72 lines
1.7 KiB
Python
Raw Normal View History

2021-03-22 20:10:20 +01:00
# external imports
2021-02-01 18:12:51 +01:00
import pytest
import tempfile
import logging
import shutil
2021-03-22 20:10:20 +01:00
# local impors
from cic_eth.task import BaseTask
#logg = logging.getLogger(__name__)
logg = logging.getLogger()
2021-02-01 18:12:51 +01:00
2021-03-22 20:10:20 +01:00
@pytest.fixture(scope='function')
def init_celery_tasks(
contract_roles,
):
BaseTask.call_address = contract_roles['DEFAULT']
2021-02-01 18:12:51 +01:00
# celery fixtures
@pytest.fixture(scope='session')
2021-03-22 20:31:03 +01:00
def celery_includes():
2021-02-01 18:12:51 +01:00
return [
# 'cic_eth.eth.bancor',
2021-03-19 19:51:30 +01:00
'cic_eth.eth.erc20',
2021-02-01 18:12:51 +01:00
'cic_eth.eth.tx',
'cic_eth.ext.tx',
2021-02-01 18:12:51 +01:00
'cic_eth.queue.tx',
2021-02-17 11:04:21 +01:00
'cic_eth.queue.balance',
2021-02-01 18:12:51 +01:00
'cic_eth.admin.ctrl',
'cic_eth.admin.nonce',
'cic_eth.admin.debug',
2021-02-01 18:12:51 +01:00
'cic_eth.eth.account',
'cic_eth.callbacks.noop',
'cic_eth.callbacks.http',
'tests.mock.filter',
2021-02-01 18:12:51 +01:00
]
@pytest.fixture(scope='session')
def celery_config():
bq = tempfile.mkdtemp()
bp = tempfile.mkdtemp()
rq = tempfile.mkdtemp()
logg.debug('celery broker queue {} processed {}'.format(bq, bp))
logg.debug('celery backend store {}'.format(rq))
yield {
'broker_url': 'filesystem://',
'broker_transport_options': {
'data_folder_in': bq,
'data_folder_out': bq,
'data_folder_processed': bp,
},
'result_backend': 'file://{}'.format(rq),
}
logg.debug('cleaning up celery filesystem backend files {} {} {}'.format(bq, bp, rq))
shutil.rmtree(bq)
shutil.rmtree(bp)
shutil.rmtree(rq)
@pytest.fixture(scope='session')
def celery_worker_parameters():
return {
# 'queues': ('celery'),
2021-02-01 18:12:51 +01:00
}
@pytest.fixture(scope='session')
def celery_enable_logging():
return True