示例#1
0
def test_submit_workflow(requests, app, tmpdir):
    app.config['postproc_server'] = 'http://127.0.0.1:5000'
    app.config['mode'] = 'scanner'
    client = app.test_client()
    wfid = create_workflow(client)
    with mock.patch('spreadsplug.web.task_queue') as mock_tq:
        mock_tq.task.return_value = lambda x: x
        requests.post.return_value.json.return_value = {'id': 1}
        client.post('/api/workflow/{0}/submit'.format(wfid),
                    content_type="application/json",
                    data=json.dumps({'config': {'plugins': []},
                                     'server': '127.0.0.1:5000'}))
    assert requests.post.call_count == 1
示例#2
0
def test_submit_workflow(app, tmpdir):
    app.config['postproc_server'] = 'http://127.0.0.1:5000'
    app.config['mode'] = 'scanner'
    client = app.test_client()
    wfid = create_workflow(client)
    with mock.patch('spreadsplug.web.web.requests.post') as post:
        post.return_value.json = {'id': 1}
        client.post('/api/workflow/{0}/submit'.format(wfid))
    wfname = json.loads(client.get('/api/workflow/{0}'.format(wfid)).data)['name']
    for img in tmpdir.join(wfname, 'raw').listdir():
        post.assert_any_call('http://127.0.0.1:5000/api/workflow/{0}/image'
                             .format(wfid),
                             files={'file': {
                                 img.basename: img.open('rb').read()}})
示例#3
0
def test_submit_workflow(app, tmpdir):
    app.config['postproc_server'] = 'http://127.0.0.1:5000'
    app.config['mode'] = 'scanner'
    client = app.test_client()
    wfid = create_workflow(client)
    with mock.patch('spreadsplug.web.web.requests.post') as post:
        post.return_value.json = {'id': 1}
        client.post('/api/workflow/{0}/submit'.format(wfid))
    wfname = json.loads(client.get(
        '/api/workflow/{0}'.format(wfid)).data)['name']
    for img in tmpdir.join(wfname, 'raw').listdir():
        post.assert_any_call(
            'http://127.0.0.1:5000/api/workflow/{0}/image'.format(wfid),
            files={'file': {
                img.basename: img.open('rb').read()
            }})
示例#4
0
def test_submit_workflow(requests, app, tmpdir):
    app.config['postproc_server'] = 'http://127.0.0.1:5000'
    app.config['mode'] = 'scanner'
    client = app.test_client()
    wfid = create_workflow(client)
    with mock.patch('spreadsplug.web.task_queue') as mock_tq:
        mock_tq.task.return_value = lambda x: x
        requests.post.return_value.json.return_value = {'id': 1}
        client.post('/api/workflow/{0}/submit'.format(wfid),
                    content_type="application/json",
                    data=json.dumps({
                        'config': {
                            'plugins': []
                        },
                        'server': '127.0.0.1:5000'
                    }))
    assert requests.post.call_count == 1
示例#5
0
def client(app):
    yield app.test_client()
示例#6
0
def client(app):
    yield app.test_client()