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
def registry(request): if request.param == 'simple': return SimpleRegistry() if request.param == 'global': return GlobalRegistry() raise Exception(f"Unsupported registry type: {request.param}")
def test_creation_of_simple(): registry = SimpleRegistry() assert isinstance(registry, BaseRegistry) assert isinstance(registry, SimpleRegistry)
def test_creation_of_simple_no_prefix(): registry = SimpleRegistry() assert isinstance(registry, BaseRegistry) assert isinstance(registry, SimpleRegistry) assert registry.prefix is None
def test_creation_of_simple_with_prefix_keyword(): registry = SimpleRegistry(prefix='hello') assert registry.prefix == 'hello'
def test_creation_of_simple_with_prefix_argument(): registry = SimpleRegistry('hello') assert registry.prefix == 'hello'