Skip to content

Commit c17eed6

Browse files
committed
test+docs(updates): cover pending-after-register over HTTP and update rest.rst
Extend test_updates.test.py with an integration test that registers a package and immediately fetches /updates/{id}/status, asserting a 200 response with status=pending and no progress/error keys - the end-to-end counterpart to the new UpdateManagerTest.StatusPendingRightAfterRegister unit test. Update docs/api/rest.rst to describe the new contract: after a successful POST /api/v1/updates, GET /api/v1/updates/{id}/status immediately returns 200 with {"status":"pending"}. 404 is reserved for packages that are not registered.
1 parent a634ea3 commit c17eed6

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

docs/api/rest.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,10 @@ Without such a plugin, all endpoints return ``501 Not Implemented``.
11431143
11441144
**Status values:** ``pending``, ``inProgress``, ``completed``, ``failed``
11451145

1146+
A successful ``POST /api/v1/updates`` seeds a ``pending`` status for the package,
1147+
so this endpoint returns ``200`` with ``{"status": "pending"}`` immediately after
1148+
registration, before any ``prepare`` or ``execute`` call.
1149+
11461150
When ``status`` is ``failed``, an ``error`` object is included:
11471151

11481152
.. code-block:: json
@@ -1155,7 +1159,7 @@ Without such a plugin, all endpoints return ``501 Not Implemented``.
11551159
}
11561160
}
11571161
1158-
- **404 Not Found:** No status available (package not found or no operation started)
1162+
- **404 Not Found:** Package is not registered
11591163

11601164
Cyclic Subscriptions
11611165
--------------------

src/ros2_medkit_integration_tests/test/features/test_updates.test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,20 @@ class TestUpdatesPrepareExecute(_UpdatesTestMixin, GatewayTestCase):
353353
BASE_URL = f'http://127.0.0.1:{PORT_WITH_PLUGIN}{API_BASE_PATH}'
354354
MIN_EXPECTED_APPS = 0
355355

356+
# @verifies REQ_INTEROP_094
357+
def test_00_status_pending_right_after_register(self):
358+
"""GET /status returns 200 pending immediately after POST /updates."""
359+
self.register_package('test-pending-after-register')
360+
r = requests.get(
361+
f'{self.BASE_URL}/updates/test-pending-after-register/status',
362+
timeout=5,
363+
)
364+
self.assertEqual(r.status_code, 200)
365+
data = r.json()
366+
self.assertEqual(data.get('status'), 'pending')
367+
self.assertNotIn('progress', data)
368+
self.assertNotIn('error', data)
369+
356370
# @verifies REQ_INTEROP_091
357371
def test_01_prepare_returns_202(self):
358372
"""PUT /updates/{id}/prepare returns 202 Accepted."""

0 commit comments

Comments
 (0)