Coverage for dibbler / models / Product.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-13 08:11 +0000

1from __future__ import annotations 

2 

3from typing import Self 

4 

5from sqlalchemy import ( 

6 Boolean, 

7 Integer, 

8 String, 

9) 

10from sqlalchemy.orm import ( 

11 Mapped, 

12 mapped_column, 

13) 

14 

15from .Base import Base 

16 

17 

18class Product(Base): 

19 id: Mapped[int] = mapped_column(Integer, primary_key=True) 

20 """Internal database ID""" 

21 

22 # TODO: add more validation for barcode 

23 bar_code: Mapped[str] = mapped_column(String(13), unique=True) 

24 """ 

25 The bar code of the product. 

26 

27 This is a unique identifier for the product, typically a 13-digit 

28 EAN-13 code. 

29 """ 

30 

31 name: Mapped[str] = mapped_column(String(45), unique=True) 

32 """ 

33 The name of the product. 

34 

35 Please don't write fanfics here, this is not a place for that. 

36 """ 

37 

38 hidden: Mapped[bool] = mapped_column(Boolean, default=False) 

39 """ 

40 Whether the product is hidden from the user interface. 

41 

42 Hidden products are not shown in the product list, but can still be 

43 used in transactions. 

44 """ 

45 

46 def __init__( 

47 self: Self, 

48 bar_code: str, 

49 name: str, 

50 hidden: bool = False, 

51 ) -> None: 

52 self.bar_code = bar_code 

53 self.name = name 

54 self.hidden = hidden