Ejemplo n.º 1
0
def test_pre_configure_templating_detected(monkeypatch):
    """It should error when plugins clash (for templating)."""
    monkeypatch.setattr(
        'cylc.flow.parsec.fileparse.iter_entry_points', lambda x:
        [pre_configure_templating_detected, pre_configure_templating_detected])
    with pytest.raises(ParsecError):
        process_plugins(None)
Ejemplo n.º 2
0
def test_pre_configure_duplicate(monkeypatch):
    """It should error when plugins clash."""
    monkeypatch.setattr(
        'cylc.flow.parsec.fileparse.pkg_resources.iter_entry_points',
        lambda x: [
            pre_configure_basic,
            pre_configure_basic
        ]
    )
    with pytest.raises(ParsecError):
        process_plugins(None)
Ejemplo n.º 3
0
def test_pre_configure_exception(monkeypatch):
    """It should wrap plugin errors."""
    monkeypatch.setattr('cylc.flow.parsec.fileparse.iter_entry_points',
                        lambda x: [pre_configure_error])
    with pytest.raises(PluginError) as exc_ctx:
        process_plugins(None)
    # the context of the original error should be preserved in the raised
    # exception
    assert exc_ctx.value.entry_point == 'cylc.pre_configure'
    assert exc_ctx.value.plugin_name == 'pre_configure_error'
    assert str(exc_ctx.value.exc) == 'foo'
Ejemplo n.º 4
0
def test_pre_configure(monkeypatch):
    """It should call the plugin."""
    monkeypatch.setattr('cylc.flow.parsec.fileparse.iter_entry_points',
                        lambda x: [pre_configure_basic])
    extra_vars = process_plugins(None)
    assert extra_vars == {
        'env': {
            'ANSWER': '42'
        },
        'template_variables': {
            'QUESTION': 'What do you get if you multiply 7 by 6?'
        },
        'templating_detected': None
    }