Implement a basic request test creating an order
This commit is contained in:
parent
159e3d7b40
commit
fb12519123
14
app/api.py
14
app/api.py
@ -5,6 +5,8 @@ from pydantic import BaseModel, Field, condecimal, conint, constr, root_validato
|
|||||||
|
|
||||||
from app.types import Order, OrderSide, OrderType
|
from app.types import Order, OrderSide, OrderType
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
@ -39,5 +41,13 @@ class CreateOrderResponseModel(Order):
|
|||||||
response_model_by_alias=True,
|
response_model_by_alias=True,
|
||||||
)
|
)
|
||||||
async def create_order(model: CreateOrderModel):
|
async def create_order(model: CreateOrderModel):
|
||||||
# TODO: Add your implementation here
|
return CreateOrderResponseModel(
|
||||||
raise NotImplementedError()
|
id=1,
|
||||||
|
created_at=datetime.now(),
|
||||||
|
type=model.type_,
|
||||||
|
side=model.side,
|
||||||
|
instrument=model.instrument,
|
||||||
|
limit_price=model.limit_price,
|
||||||
|
quantity=model.quantity
|
||||||
|
|
||||||
|
)
|
||||||
|
11
tests/api_test.py
Normal file
11
tests/api_test.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
def test_rudimentary_request(client):
|
||||||
|
response = client.post("/orders", json={
|
||||||
|
"type": "limit",
|
||||||
|
"instrument": "US0378331005",
|
||||||
|
"limit_price": 100.00,
|
||||||
|
"quantity": 10,
|
||||||
|
"side": "buy"
|
||||||
|
})
|
||||||
|
assert response.status_code == 201
|
Loading…
x
Reference in New Issue
Block a user