-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completing full replication of test for #486
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import unittest | ||
|
||
from linkml_runtime.linkml_model import SlotDefinition | ||
from linkml_runtime.loaders import yaml_loader | ||
from linkml_runtime.utils.compile_python import compile_python | ||
|
||
from linkml.generators.pythongen import PythonGenerator | ||
from tests.test_issues.environment import env | ||
from tests.utils.test_environment import TestEnvironmentTestCase | ||
from fastapi import FastAPI | ||
from fastapi.testclient import TestClient | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.get("/") | ||
async def read_main(): | ||
return {"msg": "Hello World"} | ||
|
||
|
||
@app.get("/linkml_slot/", response_model=SlotDefinition) | ||
async def linkml_slot(name: str): | ||
slot = SlotDefinition(name, description='foo') | ||
return slot | ||
|
||
client = TestClient(app) | ||
|
||
|
||
class FastAPICase(unittest.TestCase): | ||
|
||
def test_fastapi_basic(self): | ||
""" | ||
Test basic fastAPI functionality | ||
Taken from https://fastapi.tiangolo.com/tutorial/testing/ | ||
This is expected to succeed | ||
""" | ||
response = client.get("/") | ||
assert response.status_code == 200 | ||
assert response.json() == {"msg": "Hello World"} | ||
|
||
def test_fastapi_with_linkml(self): | ||
""" | ||
Test for https://github.com/linkml/linkml/issues/486 | ||
Currently fails with | ||
``` | ||
TypeError: non-default argument 'mixins' follows default argument | ||
``` | ||
""" | ||
response = client.get("/linkml_slot/") | ||
assert response.status_code == 200 | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |