Repository navigation
feature: carrierName on overdue inbound shipments (spec → red test → implementation) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: spec-demo-base
Are you sure you want to change the base?
Changes from all commits
656be62
96f8dbb
a68e999
3bbfe0c
ddd2bd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,6 +355,47 @@ def test_criterion_28_unsupported_sort_is_rejected(client): | |
| assert response.json()["errorCode"] == 400 | ||
|
|
||
|
|
||
| def _set_carrier(client, shipment_id, person_id): | ||
| response = client.request( | ||
| "POST", f"/api/shipments/{shipment_id}/tracking", | ||
| json={"carrierId": person_id}, | ||
| ) | ||
| assert response.status_code == 200 | ||
| return response | ||
|
|
||
|
|
||
| def test_criterion_31_carrier_name_reports_the_shipment_carrier(client): | ||
| """Criterion 31: carrierName is the carrier display name, null when unset.""" | ||
| person = client.get_json("/api/persons", params={"max": 1})["data"][0] | ||
| expected_delivery = (date.today() - timedelta(days=4)).isoformat() | ||
| with_carrier = _create_shipment( | ||
| client, f"{TEST_PREFIX} carrier", expected_delivery=expected_delivery, | ||
| ) | ||
| without_carrier = _create_shipment( | ||
| client, f"{TEST_PREFIX} no carrier", expected_delivery=expected_delivery, | ||
| ) | ||
| try: | ||
| _set_carrier(client, with_carrier, person["id"]) | ||
| rows = {row["id"]: row for row in _rows(client, max=500)["data"]} | ||
| missing = sorted( | ||
| rows[shipment_id]["shipmentNumber"] | ||
| for shipment_id in rows | ||
| if "carrierName" not in rows[shipment_id] | ||
| ) | ||
| assert not missing, f"rows without a carrierName key: {missing}" | ||
| carrier_row = rows[with_carrier] | ||
| assert carrier_row["carrierName"] == person["name"], ( | ||
| f"expected carrierName {person['name']!r}, got {carrier_row['carrierName']!r}" | ||
| ) | ||
| no_carrier_row = rows[without_carrier] | ||
| assert no_carrier_row["carrierName"] is None, ( | ||
| f"expected null carrierName, got {no_carrier_row['carrierName']!r}" | ||
| ) | ||
| finally: | ||
| _delete_shipment(client, with_carrier) | ||
| _delete_shipment(client, without_carrier) | ||
|
|
||
|
Comment on lines
+367
to
+397
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: New test is inserted between criteria 28 and 29, breaking file ordering
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional. The new criterion is numbered 31 rather than inserted at 29 so the existing criteria numbers and the test names derived from them stay stable; the test was appended to match. The acceptance-criteria doc notes the same reasoning. |
||
|
|
||
| def test_criterion_29_session_is_required(): | ||
| """Criterion 29: an unauthenticated session returns 401.""" | ||
| from obx import BASE_URL | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4305,6 +4305,7 @@ react.stockMovement.column.name.label=Name | |
| react.stockMovement.column.dateCreated.label=Date Created | ||
| react.stockMovement.column.expectedReceiptDate=Expected Receipt Date | ||
| react.stockMovement.column.daysLate.label=Days Late | ||
| react.stockMovement.column.carrier.label=Carrier | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Only the English message bundle gains the new Carrier label
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional — matches how the adjacent |
||
| react.stockMovement.overdue.label=Overdue | ||
| react.stockMovement.outbound.filters.requisitionStatus.label=Requisition Status | ||
| react.stockMovement.outbound.filters.requestType.label=Request type | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ class ShipmentExceptionService { | |
| destination : locationReference(shipment.destination), | ||
| expectedShippingDate : shipment.expectedShippingDate, | ||
| expectedDeliveryDate : shipment.expectedDeliveryDate, | ||
| carrierName : shipment.carrier?.name, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Carrier resolution adds one lazy association load per overdue row
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accurate, and accepted: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Lazy carrier association is accessed the same way as the endpoint the author reports 500s
Was this helpful? React with 👍 or 👎 to provide feedback. Debug |
||
| daysLate : daysLate, | ||
| status : shipment.status?.code?.name(), | ||
| shipmentItemCount : shipment.shipmentItemCount ?: shipment.shipmentItems?.size() ?: 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,13 @@ info: | |
| PARTIALLY_RECEIVED, RECEIVED). Row status is derived from getStatus(), which | ||
| can return PENDING, SHIPPED, PARTIALLY_RECEIVED or RECEIVED; CREATED is | ||
| unreachable via getStatus(). There is no CANCELLED shipment status; a | ||
| cancellation is recorded as a shipment event with EventCode.CANCELLED. | ||
| version: 0.1.0 | ||
| cancellation is recorded as a shipment event with EventCode.CANCELLED. The | ||
| party responsible for carrying the goods is Shipment.carrier, a nullable | ||
| association to core.Person ("the person or organization that actually | ||
| carries the goods from A to B"), whose display name is Person.getName() | ||
| ("firstName lastName"); ShipmentApiController already serializes it as | ||
| carrier: {id, name, email}. | ||
| version: 0.2.0 | ||
| servers: | ||
| - url: http://localhost:8080/openboxes | ||
| description: Local Docker baseline (docs/migration/RUNNING_LOCALLY.md) | ||
|
|
@@ -69,6 +74,12 @@ paths: | |
| Rows with daysLate below minDaysLate are excluded. | ||
|
|
||
|
|
||
| Each row also carries carrierName, the display name of the party | ||
| responsible for carrying the shipment (Shipment.carrier, a nullable | ||
| Person association), so a manager can chase the right carrier straight | ||
| from the exception list. It is null when no carrier is recorded. | ||
|
|
||
|
|
||
| The result set is paginated with the standard max/offset params and | ||
| sorted by daysLate descending (most overdue first) by default. max | ||
| defaults to 50 when omitted; values above 500 are rejected with 400. | ||
|
|
@@ -201,6 +212,7 @@ components: | |
| - expectedDeliveryDate | ||
| - daysLate | ||
| - status | ||
| - carrierName | ||
| properties: | ||
| id: | ||
| $ref: '../components/common.yaml#/components/schemas/Id' | ||
|
|
@@ -248,6 +260,15 @@ components: | |
| received or delivered shipments are excluded; a | ||
| PARTIALLY_RECEIVED shipment is reported only when it has neither a | ||
| RECEIVED nor a DELIVERED event. | ||
| carrierName: | ||
| type: string | ||
| nullable: true | ||
| description: > | ||
| Display name of the carrier responsible for the shipment, from | ||
| Shipment.carrier.name (Person.getName(), i.e. "firstName | ||
| lastName"). Null when the shipment has no carrier: the carrier | ||
| association is nullable in the domain and is not required to send | ||
| a shipment. Not sortable or filterable in this version. | ||
|
Comment on lines
+263
to
+271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: carrierName documented as always present but not in the schema's required list The endpoint description and acceptance criterion 31 both state that every row carries Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction to my previous reply — I was wrong that the schema has no |
||
| shipmentItemCount: | ||
| type: integer | ||
| description: Number of shipment items, for context on the exception list. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: New criterion-31 test can be flaky when more than 500 overdue rows exist
The test reads a single page with
max=500and then looks up its two freshly created shipments in that page (rows[with_carrier],rows[without_carrier]). On a database with more than 500 qualifying overdue inbound shipments, or if the defaultdaysLate descordering pushes the 4-day-late fixtures past the page boundary, the lookups raiseKeyErrorrather than a meaningful assertion failure. Filtering withminDaysLate/origin/destinationor paging through the result set would make the assertion deterministic.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real limitation, left as-is for now: narrowing with
minDaysLate/originwould change the test whose RED output is quoted in the description, and the demo dataset has far fewer than 500 overdue inbound rows. Worth tightening (filter byminDaysLate=4plus the seeded origin) in a follow-up if this suite ever runs against a production-sized database.