From d2cb557f8ad32065231c6998b6bddc9986f1a16d Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 13 Apr 2019 11:02:10 +0200 Subject: [PATCH] Rename Product.weight to Product.unit --- copanier/models.py | 7 +++---- tests/test_views.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/copanier/models.py b/copanier/models.py index 04bf275..1b32c12 100644 --- a/copanier/models.py +++ b/copanier/models.py @@ -48,7 +48,6 @@ class Base: try: setattr(self, name, self.cast(type_, value)) except (TypeError, ValueError): - raise raise ValueError(f"Wrong value for field `{name}`: `{value}`") def cast(self, type, value): @@ -92,7 +91,7 @@ class Product(Base): name: str ref: str price: price_field - weight: str = "" + unit: str = "" description: str = "" url: str = "" img: str = "" @@ -100,8 +99,8 @@ class Product(Base): @property def label(self): out = self.name - if self.weight: - out += f" ({self.weight})" + if self.unit: + out += f" ({self.unit})" return out diff --git a/tests/test_views.py b/tests/test_views.py index 6192eb4..98e4aac 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -101,6 +101,6 @@ async def test_export_products(client, delivery): resp = await client.get(f"/livraison/{delivery.id}/exporter/produits") wb = load_workbook(filename=BytesIO(resp.body)) assert list(wb.active.values) == [ - ("name", "ref", "price", "weight", "description", "url", "img"), + ("name", "ref", "price", "unit", "description", "url", "img"), ("Lait", "123", 1.5, None, None, None, None), ]