Exemplo n.º 1
0
def test_purge_plugins():
    from temboardagent.cli import Application, MergedConfiguration

    app = Application()
    app.plugins = dict(destroyme=1, keepme=1)
    app.config = MergedConfiguration()
    app.config.update(dict(temboard=dict(plugins=['keepme'])))
    app.purge_plugins()
    assert 'destroyme' not in app.plugins
Exemplo n.º 2
0
def test_reload(mocker):
    mocker.patch('temboardagent.cli.Application.read_file', autospec=True)
    mocker.patch('temboardagent.cli.Application.apply_config', autospec=True)

    from temboardagent.cli import Application

    app = Application()
    app.config = mocker.Mock(name='config')
    app.reload()
Exemplo n.º 3
0
def test_apply_config_without_plugins(mocker):
    mod = 'temboardagent.cli.'
    mocker.patch(mod + 'Postgres', autospec=True)
    mocker.patch(mod + 'Application.setup_logging', autospec=True)
    from temboardagent.cli import Application

    app = Application(with_plugins=False)
    app.config_sources = dict()
    app.config = mocker.Mock(name='config')
    app.config.postgresql = dict()

    app.apply_config()

    assert app.postgres
    assert app.setup_logging.called is True
Exemplo n.º 4
0
def test_create_plugins(mocker):
    mocker.patch(
        'temboardagent.cli.Application.fetch_plugin', autospec=True)
    llp = mocker.patch('temboardagent.cli.load_legacy_plugins', autospec=True)
    from temboardagent.cli import Application

    app = Application()
    app.config = mocker.Mock(name='config')
    app.config.temboard.plugins = ['legacy', 'ng']

    llp.return_value = dict(legacy=dict())

    app.create_plugins()

    assert 'legacy' not in app.plugins
    assert 'legacy' in app.config.plugins
    assert 'ng' in app.plugins
    assert 'ng' not in app.config.plugins
Exemplo n.º 5
0
def _test_apply_config_with_plugins(mocker):
    mod = 'temboardagent.cli.'
    mocker.patch(mod + 'Postgres', autospec=True)
    mocker.patch(mod + 'Application.setup_logging', autospec=True)
    cp = mocker.patch(mod + 'Application.create_plugins', autospec=True)
    mocker.patch(mod + 'Application.update_plugins', autospec=True)
    mocker.patch(mod + 'Application.purge_plugins', autospec=True)
    from temboardagent.cli import Application

    app = Application()
    app.config_sources = dict()
    app.config = mocker.Mock(name='config')
    app.config.postgresql = dict()
    cp.return_value = ['plugin']

    app.apply_config()

    assert app.postgres
    assert app.setup_logging.called is True
    assert app.update_plugins.called is True
    assert app.purge_plugins.called is True
Exemplo n.º 6
0
from temboardagent.errors import UserError
from temboardagent.cli import Application
from temboardagent.scheduler import taskmanager
from temboardagent.scripts.agent import WorkerPoolService
from temboardagent.scripts.agent import SchedulerService
from temboardagent.configuration import MergedConfiguration
from temboardagent.routing import Router

import pgbadger

import pytest

empty_app = Application()

empty_app.config = MergedConfiguration()

task_queue = taskmanager.Queue()
event_queue = taskmanager.Queue()

empty_app.worker_pool = WorkerPoolService(app=empty_app,
                                          name=u'worker pool',
                                          task_queue=task_queue,
                                          event_queue=event_queue)
empty_app.scheduler = SchedulerService(app=empty_app,
                                       name=u'worker pool',
                                       task_queue=task_queue,
                                       event_queue=event_queue)

empty_app.router = Router()