-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b946499
commit a8d263d
Showing
9 changed files
with
72 additions
and
32 deletions.
There are no files selected for viewing
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,40 @@ | ||
####Adds higher directory to python modules path.#### | ||
import sys | ||
sys.path.append("..") | ||
####Adds higher directory to python modules path.#### | ||
|
||
from src.main import app # assuming your FastAPI app instance is named 'app' | ||
from fastapi.testclient import TestClient | ||
|
||
client = TestClient(app) | ||
|
||
def test_calc_spectrum(): | ||
payload_data = { | ||
"species": [ | ||
{ | ||
"molecule": "CO", | ||
"mole_fraction": 0.2 | ||
} | ||
], | ||
"mode": "absorbance", | ||
"database": "hitran", | ||
"tgas": 300, | ||
"min_wavenumber_range": 1900, | ||
"max_wavenumber_range": 2300, | ||
"pressure": 1.01325, | ||
"path_length": 11, | ||
"use_simulate_slit": 'true', | ||
"simulate_slit": 5, | ||
"wavelength_units": "1/u.cm", | ||
"path_length_units": "u.km", | ||
"pressure_units": "cds.atm" | ||
} | ||
response = client.post("/calculate-spectrum", json=payload_data) | ||
|
||
data = response.json()["data"] | ||
assert response.status_code == 200 | ||
assert "x" in data | ||
assert "y" in data | ||
assert "units" in data | ||
|
||
|
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,18 @@ | ||
from src.main import app | ||
from fastapi.testclient import TestClient | ||
|
||
client = TestClient(app) | ||
|
||
def test_download_spec(): | ||
payload_data = { | ||
# provide your payload data here | ||
} | ||
response = client.post("/download-spectrum", json=payload_data) | ||
|
||
assert response.status_code == 200 | ||
assert response.headers["content-type"] == "application/octet-stream" | ||
|
||
# You can add more assertions for response content, filename, etc. | ||
# For example: | ||
assert "filename" in response.headers | ||
assert response.headers["filename"].endswith(".spec") |
This file was deleted.
Oops, something went wrong.
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
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,7 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter() | ||
|
||
@router.get("/") | ||
async def root_handler(): | ||
return {"message": "Hello World"} |