fix(tests): fixed tests for PR celery hooks deamon

This commit is contained in:
RhodeCode Admin 2024-10-25 10:34:22 +02:00
parent 89af1f74b3
commit 6a667624ae
5 changed files with 18 additions and 9 deletions

View file

@ -20,7 +20,7 @@ import os
import time
import logging
from rhodecode.lib.config_utils import get_config
from rhodecode.lib.config_utils import get_app_config_lightweight
from rhodecode.lib.svn_txn_utils import get_txn_id_from_store
@ -68,7 +68,12 @@ def prepare_callback_daemon(extras, protocol, host, txn_id=None):
txn_id=txn_id, host=host, port=port)
case 'celery':
from rhodecode.lib.hook_daemon.celery_hooks_deamon import CeleryHooksCallbackDaemon
callback_daemon = CeleryHooksCallbackDaemon(get_config(extras['config']))
config = get_app_config_lightweight(extras['config'])
task_queue = config.get('celery.broker_url')
task_backend = config.get('celery.result_backend')
callback_daemon = CeleryHooksCallbackDaemon(task_queue, task_backend)
case 'local':
from rhodecode.lib.hook_daemon.hook_module import Hooks
callback_daemon = HooksModuleCallbackDaemon(Hooks.__module__)

View file

@ -24,10 +24,12 @@ class CeleryHooksCallbackDaemon(BaseHooksCallbackDaemon):
Context manger for achieving a compatibility with celery backend
"""
def __init__(self, config):
# TODO: replace this with settings bootstrapped...
self.task_queue = config.get('app:main', 'celery.broker_url')
self.task_backend = config.get('app:main', 'celery.result_backend')
def __init__(self, task_queue, task_backend):
self.task_queue = task_queue
self.task_backend = task_backend
def __repr__(self):
return f'CeleryHooksCallbackDaemon(task_queue={self.task_queue}, task_backend={self.task_backend})'
def __repr__(self):
return f'CeleryHooksCallbackDaemon(task_queue={self.task_queue}, task_backend={self.task_backend})'

View file

@ -177,7 +177,7 @@ def baseapp(ini_config, vcsserver, http_environ_session):
from rhodecode.lib.config_utils import get_app_config
from rhodecode.config.middleware import make_pyramid_app
log.info("Using the RhodeCode configuration:{}".format(ini_config))
log.info("Using the RhodeCode configuration:%s", ini_config)
pyramid.paster.setup_logging(ini_config)
settings = get_app_config(ini_config)

View file

@ -322,6 +322,7 @@ class TestPrepareHooksDaemon(object):
'invalid',
'Http',
'HTTP',
'celerY'
))
def test_raises_on_invalid_protocol(self, protocol):
expected_extras = {

View file

@ -567,10 +567,11 @@ def test_merge_response_message(mr_type, expected_msg):
@pytest.fixture()
def merge_extras(user_regular):
def merge_extras(request, user_regular):
"""
Context for the vcs operation when running a merge.
"""
extras = {
'ip': '127.0.0.1',
'username': user_regular.username,
@ -578,7 +579,7 @@ def merge_extras(user_regular):
'action': 'push',
'repository': 'fake_target_repo_name',
'scm': 'git',
'config': 'fake_config_ini_path',
'config': request.config.getini('pyramid_config'),
'repo_store': '',
'make_lock': None,
'locked_by': [None, None, None],