def test_global_registry_with_minimal_signature(mocker, resource): cause = mocker.Mock(resource=resource, event=None, diff=None) registry = GlobalRegistry() registry.register_cause_handler(resource.group, resource.version, resource.plural, some_fn) handlers = registry.get_cause_handlers(cause) assert len(handlers) == 1 assert handlers[0].fn is some_fn
def test_global_registry_with_minimal_signature(mocker, resource): cause = mocker.Mock(resource=resource, event=None, diff=None) registry = GlobalRegistry() with pytest.deprecated_call(match=r"use OperatorRegistry.register_resource_changing_handler\(\)"): registry.register_cause_handler(resource.group, resource.version, resource.plural, some_fn) with pytest.deprecated_call(match=r"use OperatorRegistry.get_resource_changing_handlers\(\)"): handlers = registry.get_cause_handlers(cause) assert len(handlers) == 1 assert handlers[0].fn is some_fn
def test_global_registry_with_minimal_signature(cause_factory, resource): cause = cause_factory() registry = GlobalRegistry() with pytest.deprecated_call(match=r"use @kopf.on"): registry.register_cause_handler(resource.group, resource.version, resource.plural, some_fn) with pytest.deprecated_call(match=r"cease using the internal registries"): handlers = registry.get_cause_handlers(cause) assert len(handlers) == 1 assert handlers[0].fn is some_fn
def test_resources(): registry = GlobalRegistry() registry.register_cause_handler('group1', 'version1', 'plural1', some_fn) registry.register_cause_handler('group2', 'version2', 'plural2', some_fn) resources = registry.resources assert isinstance(resources, collections.abc.Collection) assert len(resources) == 2 resource1 = Resource('group1', 'version1', 'plural1') resource2 = Resource('group2', 'version2', 'plural2') assert resource1 in resources assert resource2 in resources
def test_resources(): registry = GlobalRegistry() with pytest.deprecated_call(match=r"use @kopf.on"): registry.register_cause_handler('group1', 'version1', 'plural1', some_fn) with pytest.deprecated_call(match=r"use @kopf.on"): registry.register_cause_handler('group2', 'version2', 'plural2', some_fn) resources = registry.resources assert isinstance(resources, collections.abc.Collection) assert len(resources) == 2 resource1 = Resource('group1', 'version1', 'plural1') resource2 = Resource('group2', 'version2', 'plural2') assert resource1 in resources assert resource2 in resources