Initialize Article Data Manager project
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
|
||||
from article_data_manager.models import Article
|
||||
|
||||
|
||||
def test_article_number_is_string_and_preserves_leading_zero() -> None:
|
||||
article = Article(nr="000123", name="Example")
|
||||
|
||||
assert article.nr == "000123"
|
||||
|
||||
|
||||
def test_article_number_rejects_numeric_value() -> None:
|
||||
with pytest.raises(TypeError):
|
||||
Article(nr=123) # type: ignore[arg-type]
|
||||
@@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from article_data_manager.validation import normalize_article_number
|
||||
|
||||
|
||||
def test_normalize_article_number_trims_but_preserves_leading_zero() -> None:
|
||||
assert normalize_article_number(" 000123 ") == "000123"
|
||||
|
||||
|
||||
def test_normalize_article_number_rejects_non_string() -> None:
|
||||
with pytest.raises(TypeError):
|
||||
normalize_article_number(123) # type: ignore[arg-type]
|
||||
@@ -0,0 +1,12 @@
|
||||
from pathlib import Path
|
||||
|
||||
from article_data_manager.importers.csv_inspection import inspect_csv
|
||||
|
||||
|
||||
def test_inspect_csv_detects_fixture_shape() -> None:
|
||||
result = inspect_csv(Path("tests/fixtures/production-key-data.csv"))
|
||||
|
||||
assert result.delimiter == ","
|
||||
assert result.row_count == 5
|
||||
assert result.columns[:4] == ("SL_COMPANY_NO", "PHG", "PG", "SL_ITEM_NO")
|
||||
assert "ROP_PRODUCT_WIDTH" in result.columns
|
||||
@@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
|
||||
from article_data_manager.validation.numbers import parse_decimal
|
||||
|
||||
|
||||
def test_parse_decimal_accepts_comma_decimal() -> None:
|
||||
assert parse_decimal("6,00") == 6.0
|
||||
|
||||
|
||||
def test_parse_decimal_accepts_point_decimal() -> None:
|
||||
assert parse_decimal("1.20") == 1.2
|
||||
|
||||
|
||||
def test_parse_decimal_maps_empty_value_to_none() -> None:
|
||||
assert parse_decimal("") is None
|
||||
|
||||
|
||||
def test_parse_decimal_rejects_ambiguous_number() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
parse_decimal("1.234,56")
|
||||
Reference in New Issue
Block a user