Skip to content

refactor(services): migrate to rosapi_service()/rosapi_type(), add tool tests (step4)#316

Merged
mokcontoro merged 11 commits intofeature/step2from
feature/step4
Apr 6, 2026
Merged

refactor(services): migrate to rosapi_service()/rosapi_type(), add tool tests (step4)#316
mokcontoro merged 11 commits intofeature/step2from
feature/step4

Conversation

@stex2005
Copy link
Copy Markdown
Collaborator

@stex2005 stex2005 commented Apr 5, 2026

Summary

Step 4 of 6 — targets feature/step3 (#281)

  • Replace 12 hardcoded /rosapi/ strings in services.py (6 service paths + 6 type strings) with rosapi_service()/rosapi_type()
  • Integration tests call actual MCP tools (get_services, get_service_type, get_service_details, call_service) directly
  • Tests cover happy paths and negative paths (empty/whitespace input, nonexistent service)

Changes

  • ros_mcp/tools/services.py — import helpers, replace 12 hardcoded strings (+13 -12)
  • tests/integration/test_services.py — 12 tests:
    • get_services: returns services, includes rosapi services, includes turtlesim services
    • get_service_type: known service type, empty error, whitespace error
    • get_service_details: spawn details, empty error, whitespace error
    • call_service: clear (no args), spawn turtle (with args), nonexistent service (error)
  • tests/integration/scripts/run-services-tests.sh — per-module test runner

Testing

12 tests pass on Jazzy (native), verified one-by-one against live rosbridge + turtlesim.

PR stack

Step PR Status
Step 0: detection + Docker infra #276 merged
Step 1: connection + robot config #278 merged
Step 2: nodes #280 open
Step 3: topics #281 open
Step 4: services this PR open
Step 5: actions + parameters (not created)
Step 6: resources (not created)

stex2005 added 11 commits April 5, 2026 10:51
run-tests.sh now accepts optional second arg: distro + module
e.g. ./run-tests.sh humble topics

Per-module wrappers: run-connection-tests.sh, run-detect_version-tests.sh,
run-nodes-tests.sh, run-topics-tests.sh
- Add tests for subscribe_for_duration, publish_once, publish_for_durations
- Add end-to-end test: publish cmd_vel, verify turtle moves via pose
- Extract _get_type() helper to guard against missing type responses
- Relax published_count assertion (rosbridge timing varies by distro)
- All 8 topic tools now tested (20 tests)
@stex2005 stex2005 changed the base branch from feature/step3 to feature/step2 April 5, 2026 18:10
@mokcontoro mokcontoro merged commit e07b5a1 into feature/step2 Apr 6, 2026
stex2005 added a commit that referenced this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants