Refactor transport calculation into shared domain
This commit is contained in:
@@ -8,6 +8,7 @@ from roll_calculation import (
|
||||
CalculationState,
|
||||
_canonical_name,
|
||||
calculate_roll,
|
||||
get_article,
|
||||
modify_calculation,
|
||||
)
|
||||
|
||||
@@ -90,6 +91,35 @@ class RollCalculationTests(unittest.TestCase):
|
||||
def calculate_fixture(self, payload):
|
||||
return calculate_roll(payload, article_repository=self.repository)
|
||||
|
||||
def test_public_get_article_uses_repository_resolution_and_projection(self):
|
||||
result = get_article("00123", article_repository=self.repository)
|
||||
|
||||
self.assertEqual(result["status"], "resolved")
|
||||
self.assertEqual(result["article"]["number"], "00123")
|
||||
self.assertEqual(result["article"]["width_m"], 4.9)
|
||||
self.assertEqual(result["article"]["area_weight_g_m2"], 1000.0)
|
||||
|
||||
def test_public_get_article_preserves_not_found_ambiguous_and_conflict_results(self):
|
||||
self.assertEqual(
|
||||
get_article("does-not-exist", article_repository=self.repository)["status"],
|
||||
"article_not_found",
|
||||
)
|
||||
self.assertEqual(
|
||||
get_article(
|
||||
article_name_hint="Duplicated Product",
|
||||
article_repository=self.repository,
|
||||
)["status"],
|
||||
"article_ambiguous",
|
||||
)
|
||||
self.assertEqual(
|
||||
get_article(
|
||||
"00123",
|
||||
"Other product",
|
||||
article_repository=self.repository,
|
||||
)["status"],
|
||||
"article_conflict",
|
||||
)
|
||||
|
||||
def test_headless_matches_representative_existing_ui_values(self):
|
||||
result = calculate_roll(representative_request())
|
||||
calculation = result["calculation"]
|
||||
|
||||
Reference in New Issue
Block a user