-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip rebase on remote branch & add wip work for actually saving data
- Loading branch information
Showing
11 changed files
with
114 additions
and
29 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,4 @@ | ||
**/.share | ||
**/.git | ||
**/.venv | ||
.venv |
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
Empty file.
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
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
Empty file.
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,64 @@ | ||
from fastapi.testclient import TestClient | ||
import pytest | ||
import uuid as uuid_lib | ||
|
||
|
||
TEST_SERVER_BASE_URL = "http://localhost.com/v2" | ||
|
||
|
||
def get_uuid() -> str: | ||
# @TODO: make this constant and require mongo to always be clean? | ||
generated = uuid_lib.uuid4() | ||
|
||
return str(generated) | ||
|
||
|
||
def get_client(**kwargs) -> TestClient: | ||
from fastapi.responses import JSONResponse | ||
from fastapi import Request | ||
import traceback | ||
|
||
from ..app import app | ||
|
||
@app.exception_handler(Exception) | ||
def generic_exception_handler(request: Request, exc: Exception): | ||
return JSONResponse( | ||
status_code=500, | ||
content=traceback.format_exception(exc, value=exc, tb=exc.__traceback__), | ||
) | ||
|
||
return TestClient(app, base_url=TEST_SERVER_BASE_URL, **kwargs) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def api_client() -> TestClient: | ||
client = get_client(raise_server_exceptions=False) | ||
# authenticate_client(client) # @TODO: DELETEME | ||
|
||
return client | ||
|
||
|
||
def test_create_thing(api_client: TestClient): | ||
study_uuid = get_uuid() | ||
study = { | ||
"uuid": study_uuid, | ||
"version": 0, | ||
"release_date": "2023-01-31", | ||
"accession_id": study_uuid, | ||
"title": "Test BIA study", | ||
"description": "description", | ||
"licence": "CC_BY_4.0", | ||
"see_also": [], | ||
"model": {"type_name": "Study", "version": 1}, | ||
"author": [ | ||
{ | ||
"display_name": "Georg Brenneis", | ||
"contact_email": "[email protected]", | ||
"affiliation": [{"display_name": "University of Vienna"}], | ||
} | ||
], | ||
"attribute": {}, | ||
} | ||
|
||
rsp = api_client.post("private/study", json=study) | ||
assert rsp.status_code == 201, rsp.json() |
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