Esempio n. 1
0
def test_process_registry_add_by_name_and_namespace():
    reg = ProcessRegistry()
    reg.add_spec_by_name("max", namespace="foo")
    assert not reg.contains("max")
    assert reg.contains("max", namespace="foo")
    with pytest.raises(ProcessUnsupportedException):
        reg.get_spec('max')
    spec = reg.get_spec('max', namespace="foo")
    assert spec['id'] == 'max'
    assert 'largest value' in spec['description']
    assert all(k in spec for k in ['parameters', 'returns'])
Esempio n. 2
0
def test_process_registry_add_function_namespace():
    reg = ProcessRegistry()

    @reg.add_function(name="max", namespace="foo")
    def madmax(*args):
        return max(*args)

    assert not reg.contains("max")
    assert reg.contains("max", namespace="foo")
    spec = reg.get_spec('max', namespace="foo")
    assert spec['id'] == 'max'
    assert 'largest value' in spec['description']
    assert all(k in spec for k in ['parameters', 'returns'])

    assert reg.get_function('max', namespace="foo") is madmax
Esempio n. 3
0
def test_process_registry_add_by_name():
    reg = ProcessRegistry()
    reg.add_spec_by_name("max")
    assert reg.contains("max")
    spec = reg.get_spec('max')
    assert spec['id'] == 'max'
    assert 'largest value' in spec['description']
    assert all(k in spec for k in ['parameters', 'returns'])
Esempio n. 4
0
def test_process_registry_add_function_argument_names():
    reg = ProcessRegistry(argument_names=["args", "env"])

    @reg.add_function
    def max(args, env=None):
        return max(*args)

    with pytest.raises(ProcessRegistryException):

        @reg.add_function
        def min(args):
            return min(*args)

    assert reg.contains("max")
    spec = reg.get_spec('max')
    assert spec['id'] == 'max'
    assert 'largest value' in spec['description']
    assert all(k in spec for k in ['parameters', 'returns'])
    assert reg.get_function('max') is max
Esempio n. 5
0
def test_process_registry_contains():
    reg = ProcessRegistry()
    assert not reg.contains("max")
    reg.add_spec_by_name("max")
    assert reg.contains("max")