Ejemplo n.º 1
0
def redis_service(request, useredis, servicename, config):
    """docstring for local_service"""
    from Cauldron.DFW import Service
    svc = Service(servicename, config=config)
    mykw = svc['KEYWORD']
    request.addfinalizer(lambda : svc.shutdown())
    request.addfinalizer(fail_if_not_teardown)
    return svc
Ejemplo n.º 2
0
def test_duplicate_services(backend, servicename):
    """Test duplicate services."""
    from Cauldron.DFW import Service
    svc = Service(servicename, config=None)
    with pytest.raises(ValueError):
        svc2 = Service(servicename, config=None)
    svc3 = Service.get_service(servicename)
    assert svc3 is svc
Ejemplo n.º 3
0
def test_teardown(servicename, teardown_cauldron, keyword_name2, servicename2):
    """Check that teardown really does tear things down, in local mode."""
    from Cauldron.api import teardown, use
    use("local")
    from Cauldron.DFW import Service
    svc = Service(servicename2, None)
    svc[keyword_name2].modify('10')
    teardown()
    del svc

    use("local")
    from Cauldron.DFW import Service
    svc2 = Service(servicename2, None)
    assert svc2[keyword_name2].read() == None
Ejemplo n.º 4
0
def test_custom_type_nobackend(servicename, keyword_name):
    """Test custom type with no backend set up."""
    from Cauldron.types import DispatcherKeywordType

    class CustomKeyword(DispatcherKeywordType):
        """A custom keyword type"""
        counter = 0

        def __init__(self, *args, **kwargs):
            print("__init__")
            self.counter += 1
            super(CustomKeyword, self).__init__(*args, **kwargs)

    with pytest.raises(RuntimeError):
        CustomKeyword(keyword_name, "")

    from Cauldron.api import use, teardown
    try:
        use("mock")
        from Cauldron.DFW import Service
        service = Service(servicename,
                          setup=lambda s: CustomKeyword(keyword_name, s),
                          config=None)
        keyword = service[keyword_name]
        assert isinstance(keyword, CustomKeyword)
        assert keyword.counter == 1
    finally:
        teardown()
Ejemplo n.º 5
0
def test_duplicate_services(backend, servicename):
    """Test duplicate 'mock' services."""
    from Cauldron.DFW import Service
    svc = Service(servicename, config=None)
    with pytest.raises(ValueError):
        svc2 = Service(servicename, config=None)
    svc3 = Service.get_service(servicename)
    assert svc3 is svc
Ejemplo n.º 6
0
def test_client_not_started(backend, servicename):
    """Use local, but fail when a client hasn't been started yet."""
    from Cauldron.exc import ServiceNotStarted
    from Cauldron.ktl import Service
    with pytest.raises(ServiceNotStarted):
        Service(servicename)
Ejemplo n.º 7
0
def local_service(backend, servicename, config, keyword_name):
    """docstring for local_service"""
    from Cauldron.DFW import Service
    svc = Service(servicename, config=config)
    mykw = svc[keyword_name]
    return svc
Ejemplo n.º 8
0
def test_client_not_started(backend, servicename):
    """Use mock, don't fail when a client hasn't been started yet."""
    from Cauldron.ktl import Service
    Service(servicename)
Ejemplo n.º 9
0
def mock_service(backend, servicename, config, keyword_name):
    """A 'mock' service, which is forgiving."""
    from Cauldron.DFW import Service
    svc = Service(servicename, config=config)
    mykw = svc[keyword_name]
    return svc
Ejemplo n.º 10
0
def test_strict_xml(backend, servicename, xmlvar):
    """Test the XML validation in strict mode."""
    from Cauldron.api import use_strict_xml
    use_strict_xml()
    from Cauldron.DFW import Service
    svc = Service(servicename, None)