Merge in RR/image-prediction from pipeline_refactoring to tdd_refactoring
Squashed commit of the following:
commit 6989fcb3313007b7eecf4bba39077fcde6924a9a
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Mon Apr 25 09:49:49 2022 +0200
removed obsolete module
commit 7428aeee37b11c31cffa597c85b018ba71e79a1d
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Mon Apr 25 09:45:45 2022 +0200
refactoring
commit 0dcd3894154fdf34bd3ba4ef816362434474f472
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Mon Apr 25 08:57:21 2022 +0200
refactoring; removed obsolete extractor-classifier
commit 1078aa81144f4219149b3fcacdae8b09c4b905c0
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Fri Apr 22 17:18:10 2022 +0200
removed obsolete imports
commit 71f61fc5fc915da3941cf5ed5d9cc90fccc49031
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Fri Apr 22 17:16:25 2022 +0200
comment changed
commit b582726cd1de233edb55c5a76c91e99f9dd3bd13
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Fri Apr 22 17:12:11 2022 +0200
refactoring
commit 8abc9010048078868b235d6793ac6c8b20abb985
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 21:25:47 2022 +0200
formatting
commit 2c87c419fe3185a25c27139e7fcf79f60971ad24
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 21:24:05 2022 +0200
formatting
commit 50b161192db43a84464125c6d79650225e1010d6
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 21:20:18 2022 +0200
refactoring
commit 9a1446cccfa070852a5d9c0bdbc36037b82541fc
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 21:04:57 2022 +0200
refactoring
commit 6c10b55ff8e61412cb2fe5a5625e660ecaf1d7d1
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 19:48:05 2022 +0200
refactoring
commit 72e785e3e31c132ab352119e9921725f91fac9e2
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Thu Apr 21 19:43:39 2022 +0200
refactoring
commit f036ee55e6747daf31e3929bdc2d93dc5f2a56ca
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date: Wed Apr 20 18:30:41 2022 +0200
refactoring pipeline WIP
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
import json
|
|
|
|
import pytest
|
|
|
|
from image_prediction.exceptions import IntentionalTestException
|
|
from image_prediction.flask import make_prediction_server
|
|
|
|
|
|
def predict_fn(x: bytes):
|
|
x = int(x.decode())
|
|
if x == 42:
|
|
return True
|
|
else:
|
|
raise IntentionalTestException("This is intended.")
|
|
|
|
|
|
@pytest.fixture
|
|
def server():
|
|
server = make_prediction_server(predict_fn)
|
|
server.config.update({"TESTING": True})
|
|
return server
|
|
|
|
|
|
@pytest.fixture
|
|
def client(server):
|
|
return server.test_client()
|
|
|
|
|
|
def test_server_predict_success(client, mute_logger):
|
|
response = client.post("/predict", data="42")
|
|
assert json.loads(response.data)
|
|
|
|
|
|
def test_server_predict_failure(client, mute_logger):
|
|
response = client.post("/predict", data="13")
|
|
assert response.status_code == 500
|
|
|
|
|
|
def test_server_health_check(client):
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
assert response.json == "OK"
|
|
|
|
|
|
def test_server_ready_check(client):
|
|
response = client.get("/ready")
|
|
assert response.status_code == 200
|
|
assert response.json == "OK"
|