示例#1
0
def test_subhandler_declaratively(mocker, parent_handler):
    cause = mocker.MagicMock(reason=Reason.UPDATE, diff=None)

    registry = SimpleRegistry()
    subregistry_var.set(registry)

    with context([(handler_var, parent_handler)]):

        @kopf.on.this()
        def fn(**_):
            pass

    with pytest.deprecated_call(
            match=r"use ResourceChangingRegistry.get_handlers\(\)"):
        handlers = registry.get_cause_handlers(cause)

    assert len(handlers) == 1
    assert handlers[0].fn is fn
示例#2
0
def registry(request):
    if request.param == 'simple':
        return SimpleRegistry()
    if request.param == 'global':
        return GlobalRegistry()
    raise Exception(f"Unsupported registry type: {request.param}")
示例#3
0
def test_creation_of_simple():
    registry = SimpleRegistry()
    assert isinstance(registry, BaseRegistry)
    assert isinstance(registry, SimpleRegistry)
示例#4
0
def test_creation_of_simple_no_prefix():
    registry = SimpleRegistry()
    assert isinstance(registry, BaseRegistry)
    assert isinstance(registry, SimpleRegistry)
    assert registry.prefix is None
示例#5
0
def test_creation_of_simple_with_prefix_keyword():
    registry = SimpleRegistry(prefix='hello')
    assert registry.prefix == 'hello'
示例#6
0
def test_creation_of_simple_with_prefix_argument():
    registry = SimpleRegistry('hello')
    assert registry.prefix == 'hello'