[barcode] fix commit
This commit is contained in:
parent
04be0d16dc
commit
226327967e
2 changed files with 9 additions and 1 deletions
|
@ -64,6 +64,8 @@ class GetProductByBarCode(AuthorizedController):
|
||||||
product_data.kcal,
|
product_data.kcal,
|
||||||
barcode,
|
barcode,
|
||||||
)
|
)
|
||||||
return Product.from_orm(product)
|
await session.commit()
|
||||||
|
|
||||||
|
return Product.from_orm(await DBProduct.get_by_barcode(session, barcode))
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
raise HTTPException(status_code=400, detail=e.args[0])
|
raise HTTPException(status_code=400, detail=e.args[0])
|
||||||
|
|
|
@ -25,3 +25,9 @@ def test_list_product(client):
|
||||||
def test_get_product_by_barcode(client):
|
def test_get_product_by_barcode(client):
|
||||||
response = client.get("product/by_barcode", params={"barcode": "4056489666028"})
|
response = client.get("product/by_barcode", params={"barcode": "4056489666028"})
|
||||||
assert response.status_code == 200, response.json()
|
assert response.status_code == 200, response.json()
|
||||||
|
|
||||||
|
name = response.json()["name"]
|
||||||
|
|
||||||
|
response = client.get("product", params={"q": name})
|
||||||
|
assert response.status_code == 200, response.json()
|
||||||
|
assert len(response.json()["products"]) == 1
|
||||||
|
|
Loading…
Reference in a new issue