Skip to content

Commit

Permalink
Completing full replication of test for #486
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Jan 25, 2022
1 parent 7417096 commit b249825
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_issues/test_linkml_issue_486.py
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()

0 comments on commit b249825

Please sign in to comment.