Skip to content

Commit

Permalink
testing website calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pstjohn committed Feb 21, 2022
1 parent 1543eda commit 76c6ca8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion etc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies:
- python
- rdkit
- scikit-learn
- nomkl
- numpy
- uvicorn
- pytest
22 changes: 21 additions & 1 deletion src/test/test_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import json
import os
from pathlib import Path
from urllib.parse import quote

from fastapi.testclient import TestClient
from ysi_api import app

dir_path = os.path.dirname(os.path.realpath(__file__))
fastapi_client = TestClient(app)


Expand All @@ -14,7 +18,7 @@ def test_path_api():
assert data["outlier"] is True

data = fastapi_client.get("/predict/X").json()
assert data['detail'] == "Invalid smiles: X"
assert data["detail"] == "Invalid smiles: X"


def test_query_api():
Expand All @@ -24,3 +28,19 @@ def test_query_api():

data = fastapi_client.get(f"/predict?smiles={smiles}").json()
assert data["status"] == "ok"


def test_result():
data = fastapi_client.get(r"/result/C/C(=C\c1ccccc1)c1ccccc1").json()
assert "svg" in data["mol_svg"]
assert (
data["named_smiles"] == "C/C(=C\\c1ccccc1)c1ccccc1 (trans 1,2-diphenylpropene)"
)
assert data["status"] == "ok"


def test_frag():
frag = "[H]-[C](-[H])(-[C])-[C] | (Ring)"
data = fastapi_client.get(f"/frag/{quote(frag)}").json()
assert "svg" in data["frag_svg"]
assert data["status"] == "ok"

0 comments on commit 76c6ca8

Please sign in to comment.