Tests and lint pass
This commit is contained in:
parent
0502902ffe
commit
f4ad388e36
7 changed files with 11 additions and 10 deletions
|
|
@ -12,7 +12,6 @@ from common import ProblemDetails
|
||||||
from settings import settings
|
from settings import settings
|
||||||
from users.models import User
|
from users.models import User
|
||||||
from security import JwtConfig, verify_jwt
|
from security import JwtConfig, verify_jwt
|
||||||
from settings import settings
|
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
from fastapi import APIRouter, Depends, Query, Request, Response
|
from fastapi import APIRouter, Depends, Query, Response
|
||||||
|
|
||||||
import ingredients as ingredients_mod
|
import ingredients as ingredients_mod
|
||||||
import recipes
|
import recipes
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, List, Literal
|
from typing import Dict, List, Literal, cast
|
||||||
|
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
from fastapi import APIRouter, Depends, Request, Response
|
from fastapi import APIRouter, Depends, Request, Response
|
||||||
|
|
@ -109,11 +109,15 @@ def _to_meal_item(item: shopping.ShoppingListItem) -> RequestedMealItem:
|
||||||
|
|
||||||
def _to_shopping_list_out(sl: shopping.ShoppingList) -> ShoppingListOut:
|
def _to_shopping_list_out(sl: shopping.ShoppingList) -> ShoppingListOut:
|
||||||
# Map internal enum value "" to outward-friendly "home"
|
# Map internal enum value "" to outward-friendly "home"
|
||||||
outward_store = "home" if sl.store_name == StoreEnum.home else sl.store_name.value
|
if sl.store_name == StoreEnum.home:
|
||||||
|
outward_store: Literal["woolworths", "coles", "home"] = "home"
|
||||||
|
else:
|
||||||
|
# Remaining enum values are 'woolworths' or 'coles'
|
||||||
|
outward_store = cast(Literal["woolworths", "coles"], sl.store_name.value)
|
||||||
return ShoppingListOut(
|
return ShoppingListOut(
|
||||||
id=sl.id,
|
id=sl.id,
|
||||||
created_date=sl.created_date,
|
created_date=sl.created_date,
|
||||||
store_name=outward_store,
|
store_name=outward_store,
|
||||||
purchased_by_id=sl.purchased_by_id,
|
purchased_by_id=sl.purchased_by_id,
|
||||||
purchased_by=sl.purchased_by,
|
purchased_by=sl.purchased_by,
|
||||||
items=[_to_ingredient_item(i) for i in sl.items],
|
items=[_to_ingredient_item(i) for i in sl.items],
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ from api.shopping import (
|
||||||
_to_ingredient_item,
|
_to_ingredient_item,
|
||||||
_to_meal_item,
|
_to_meal_item,
|
||||||
_to_shopping_list_out,
|
_to_shopping_list_out,
|
||||||
IngredientPurchaseItemIn,
|
|
||||||
PurchaseListIn,
|
PurchaseListIn,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import ClassVar, Optional
|
from typing import ClassVar
|
||||||
|
|
||||||
from common import ApiModel
|
from common import ApiModel
|
||||||
|
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -169,7 +169,7 @@ def create_app() -> FastAPI:
|
||||||
app.include_router(households_router.router, prefix="/api/v1", tags=["v2"]) # new
|
app.include_router(households_router.router, prefix="/api/v1", tags=["v2"]) # new
|
||||||
# Mount household-scoped endpoints
|
# Mount household-scoped endpoints
|
||||||
try:
|
try:
|
||||||
app.include_router(households_router.scoped, prefix="/api/v1", tags=["v2"]) # type: ignore[attr-defined]
|
app.include_router(households_router.scoped, prefix="/api/v1", tags=["v2"])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
app.include_router(recipes_v2_router.router, prefix="/api/v1", tags=["v2"]) # new
|
app.include_router(recipes_v2_router.router, prefix="/api/v1", tags=["v2"]) # new
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,8 @@ class TestAuthAndHouseholdsV2(unittest.IsolatedAsyncioTestCase):
|
||||||
# List households (migration created default household 'default' and membership set to admin)
|
# List households (migration created default household 'default' and membership set to admin)
|
||||||
r = self.client.get("/api/v1/users/me/households", headers=headers)
|
r = self.client.get("/api/v1/users/me/households", headers=headers)
|
||||||
assert r.status_code == 200, r.text
|
assert r.status_code == 200, r.text
|
||||||
households = r.json()
|
|
||||||
|
|
||||||
# Create a new household
|
# Create a new household
|
||||||
r = self.client.post("/api/v1/households", headers=headers, json={"name": "Family"})
|
r = self.client.post("/api/v1/households", headers=headers, json={"name": "Family"})
|
||||||
assert r.status_code == 200, r.text
|
assert r.status_code == 200, r.text
|
||||||
created = r.json()
|
created = r.json()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue