| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import os
- from fastapi.testclient import TestClient
- from app.db import export_order_to_xlsx, fetch_order_product_list
- from app.main import app
- from app.parser import read_file
- from app.read_settings import read_settings
- from app.schema import ProductShippingMeta
- client = TestClient(app)
- def test_export_order_to_xlsx(capsys):
- """This test does not test anything in here, but simply makes sure
- that the expected xlsx output file is produced and written to
- disk.
- """
- settings = read_settings("settings.toml")
- filename = "orders"
- orders = read_file(
- settings.git_repo, filename, settings.document_match, settings.block_types
- )
- order = orders.blocks[-1]
- product_list = fetch_order_product_list(
- order.order_id, settings.git_repo, settings.local_db.filepath
- )
- products_shipping_meta = []
- for product_info in product_list:
- product = read_file(settings.git_repo, f"products/{product_info.filename}", settings.document_match, settings.block_types)
- products_shipping_meta.append(
- ProductShippingMeta(
- weight=product.meta.weight,
- customs_tariff_code=product.meta.customs_tariff_code,
- origin_country_iso=product.meta.origin_country_iso,
- )
- )
- email_from = os.getenv("MAIL_FROM")
- export_order_to_xlsx(
- order,
- products_shipping_meta,
- settings.order_upload.filepath,
- settings.currency.default,
- settings.git_repo,
- email_from,
- )
|