forked from IBM/MAX-Breast-Cancer-Mitosis-Detector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added integration tests and switched to max-base image * corrected model name in .travis.yml
- Loading branch information
Showing
5 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
README.md | ||
Dockerfile | ||
.git/ | ||
tests/ | ||
/.pytest_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,4 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
/.pytest_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: python | ||
python: | ||
- 3.6 | ||
services: | ||
- docker | ||
install: | ||
- docker build -t max-breast-cancer-mitosis-detector . | ||
- docker run -it -d -p 5000:5000 max-breast-cancer-mitosis-detector | ||
before_script: | ||
- pip install pytest pycurl | ||
script: | ||
- pytest tests/test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
import pycurl | ||
import io | ||
import json | ||
|
||
|
||
def test_response(): | ||
|
||
# Test True | ||
|
||
c = pycurl.Curl() | ||
b = io.BytesIO() | ||
c.setopt(pycurl.URL, 'http://localhost:5000/model/predict') | ||
c.setopt(pycurl.HTTPHEADER, ['Accept:application/json', 'Content-Type: multipart/form-data']) | ||
c.setopt(pycurl.HTTPPOST, [('image', (pycurl.FORM_FILE, "assets/true.png"))]) | ||
c.setopt(pycurl.WRITEFUNCTION, b.write) | ||
c.perform() | ||
assert c.getinfo(pycurl.RESPONSE_CODE) == 200 | ||
c.close() | ||
response = b.getvalue() | ||
response = json.loads(response) | ||
|
||
assert response['status'] == 'ok' | ||
assert response['predictions'][0]['probability'] > 0.5 | ||
|
||
# Test False | ||
|
||
c = pycurl.Curl() | ||
b = io.BytesIO() | ||
c.setopt(pycurl.URL, 'http://localhost:5000/model/predict') | ||
c.setopt(pycurl.HTTPHEADER, ['Accept:application/json', 'Content-Type: multipart/form-data']) | ||
c.setopt(pycurl.HTTPPOST, [('image', (pycurl.FORM_FILE, "assets/false.png"))]) | ||
c.setopt(pycurl.WRITEFUNCTION, b.write) | ||
c.perform() | ||
assert c.getinfo(pycurl.RESPONSE_CODE) == 200 | ||
c.close() | ||
response = b.getvalue() | ||
response = json.loads(response) | ||
|
||
assert response['status'] == 'ok' | ||
assert response['predictions'][0]['probability'] < 0.5 | ||
|
||
|
||
if __name__ == '__main__': | ||
pytest.main([__file__]) |