Exemple #1
0
async def test_predict_async_post(mocker, job_id):
    mock_image_base64 = get_image_data()["image_data"]
    mock_data = MockData(image_data=mock_image_base64)
    mocker.patch("src.jobs.store_data_job._save_data_job", return_value=job_id)
    mocker.patch("PIL.Image.open", return_value=mock_image)
    mocker.patch("io.BytesIO", return_value=mock_image)
    result = await _predict_async_post(mock_data, job_id, mock_BackgroundTasks)
    assert result["job_id"] == job_id
async def test_predict_async_post(mocker, job_id):
    mock_image_base64 = get_image_data()['image_data']
    mock_data = MockData(image_data=mock_image_base64)
    mocker.patch('src.jobs.store_data_job._save_data_job', return_value=job_id)
    mocker.patch('PIL.Image.open', return_value=mock_image)
    mocker.patch('io.BytesIO', return_value=mock_image)
    result = await _predict_async_post(mock_data, job_id, mock_BackgroundTasks)
    assert result['job_id'] == job_id
Exemple #3
0
async def test_predict_label(mocker, output, expected):
    mock_image_base64 = get_image_data()["image_data"]
    mock_data = MockData(image_data=mock_image_base64)
    mocker.patch("PIL.Image.open", return_value=mock_image)
    mocker.patch("io.BytesIO", return_value=mock_image)
    mocker.patch("src.app.ml.active_predictor.active_predictor.predict",
                 return_value=output)
    mocker.patch("src.jobs.store_data_job._save_data_job", return_value=job_id)
    result = await _predict_label(mock_data, mock_BackgroundTasks)
    assert result["prediction"]["a"] == pytest.approx(
        expected["prediction"]["a"])
    assert "job_id" in result
async def test_predict_label(mocker, output, expected):
    mock_image_base64 = get_image_data()['image_data']
    mock_data = MockData(image_data=mock_image_base64)
    mocker.patch('PIL.Image.open', return_value=mock_image)
    mocker.patch('io.BytesIO', return_value=mock_image)
    mocker.patch('src.app.ml.active_predictor.active_predictor.predict',
                 return_value=output)
    mocker.patch('src.jobs.store_data_job._save_data_job', return_value=job_id)
    result = await _predict_label(mock_data, mock_BackgroundTasks)
    assert result['prediction']['a'] == pytest.approx(
        expected['prediction']['a'])
    assert 'job_id' in result