Exemplo n.º 1
0
def test_transform_serialize():
    args = ('arg1', 'arg2', 'arg3')
    kwargs = {'kwarg1': 'kwarg1', 'kwarg2': 'kwarg2'}
    t = Transform(*args, **kwargs)
    assert t.serialize() == {
        '__state__': {
            'args': args,
            'kwargs': kwargs
        },
        '_class': 'Transform',
        '_module': 'girder_worker_utils.transform'
    }
Exemplo n.º 2
0
def test_deserialize():
    t = Transform.deserialize({
        'args': ('a', 'b'),
        'kwargs': {
            'c': 'c',
            'd': 'd'
        }
    })
    assert t.__state__['args'] == ('a', 'b')
    assert t.__state__['kwargs'] == {'c': 'c', 'd': 'd'}
Exemplo n.º 3
0
import json

from girder_worker_utils.transform import Transform
from gw_utils_demo_app import tasks
from gw_utils_demo_app.transform import GirderFile, RaiseException, Reverse

# tasks.task.delay('foobar')
print(tasks.task(Transform('foobar')))
print(tasks.task(Reverse('foobar')))
print(tasks.task.delay('foobar').get())
print(tasks.task.delay(Reverse('foobar')).get())

data = json.loads(
    tasks.task.delay(GirderFile('55c8998f8d777f6ddc3ff818')).get())
print(data.keys())

print(tasks.task.delay(RaiseException()).get())
Exemplo n.º 4
0
def test_noop_transform():
    assert Transform('some value').transform() == 'some value'
Exemplo n.º 5
0
def test_default_transform_behavior():
    assert Transform().transform() is None
Exemplo n.º 6
0
def test_transform_json():
    args = ('arg1', 'arg2', 'arg3')
    kwargs = {'kwarg1': 'kwarg1', 'kwarg2': 'kwarg2'}
    t = Transform(*args, **kwargs)
    assert t.__json__() == t.serialize()
Exemplo n.º 7
0
def test_instantiate_transform_behavior():
    with pytest.raises(TypeError):
        Transform()