test_production_task_set_route_steps.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import unittest
  2. from app.crud.production_task_set import (
  3. collect_missing_route_ids,
  4. collect_route_ids_without_steps,
  5. )
  6. class TestCollectRouteIdsWithoutSteps(unittest.TestCase):
  7. def test_empty_when_all_routes_have_steps(self):
  8. items = [{"route_id": "r1"}, {"route_id": "r2"}]
  9. self.assertEqual(
  10. collect_route_ids_without_steps(items, {"r1", "r2"}),
  11. [],
  12. )
  13. def test_reports_routes_without_steps_deduped(self):
  14. items = [
  15. {"route_id": "r1"},
  16. {"route_id": "r2"},
  17. {"route_id": "r1"},
  18. {"route_id": None},
  19. {"route_id": ""},
  20. ]
  21. self.assertEqual(
  22. collect_route_ids_without_steps(items, {"r2"}),
  23. ["r1"],
  24. )
  25. def test_missing_route_ids_unchanged(self):
  26. items = [{"route_id": "gone"}, {"route_id": "ok"}]
  27. self.assertEqual(
  28. collect_missing_route_ids(items, {"ok"}),
  29. ["gone"],
  30. )
  31. if __name__ == "__main__":
  32. unittest.main()