Skip to content

feat: add read commands for plans, suites, and cases (#401)#402

Draft
cosmicdreams wants to merge 1 commit intogurock:mainfrom
cosmicdreams:feat/read-commands-401
Draft

feat: add read commands for plans, suites, and cases (#401)#402
cosmicdreams wants to merge 1 commit intogurock:mainfrom
cosmicdreams:feat/read-commands-401

Conversation

@cosmicdreams
Copy link

Issue being resolved: #401

Solution description

Added five read commands that fetch TestRail data as JSON to stdout, using the
existing cmd_*.py auto-discovery pattern. get_plans and get_plan are
exposed as public methods on ApiRequestHandler with caching (matching the
existing get_suites pattern). get_suites, get_cases, and get_case call
APIClient.send_get directly. All commands honour global auth flags and env vars.

Changes

  • trcli/api/api_request_handler.py — new get_plans(project_id) and
    get_plan(plan_id) public methods + private __get_all_plans with caching
  • trcli/commands/cmd_get_plans.py — list all plans for a project
  • trcli/commands/cmd_get_plan.py — fetch a single plan by ID
  • trcli/commands/cmd_get_suites.py — list all suites for a project
  • trcli/commands/cmd_get_cases.py — list cases with pagination + optional --section-id filter
  • trcli/commands/cmd_get_case.py — fetch a single case by ID
  • tests/test_cmd_get_*.py — 30 new CLI tests (happy path, error path, missing args)
  • tests/test_api_request_handler.py — 4 new handler unit tests
  • README.md — new "Reading data from TestRail" section with usage table and examples
  • CHANGELOG.MD — [Unreleased] entry

Potential impacts

  • No changes to existing commands or cli.py — new files only, plus additive
    changes to api_request_handler.py
  • New commands appear in trcli --help automatically via folder scan
  • Caching in get_plans uses the same _cache mechanism as get_suites
    no new cache behaviour introduced

Steps to test

  1. trcli -h <host> -u <user> -k <key> get_plans --project-id 1 → JSON array of plans
  2. trcli -h <host> -u <user> -k <key> get_plan --plan-id 42 → JSON plan object
  3. trcli -h <host> -u <user> -k <key> get_suites --project-id 1 → JSON array of suites
  4. trcli -h <host> -u <user> -k <key> get_cases --project-id 1 --suite-id 3 → JSON array of cases
  5. trcli -h <host> -u <user> -k <key> get_cases --project-id 1 --suite-id 3 --section-id 10 → filtered
    cases
  6. trcli -h <host> -u <user> -k <key> get_case --case-id 5001 → JSON case object
  7. python3 -m pytest -c ./tests/pytest.ini -W ignore::pytest.PytestCollectionWarning tests/test_cmd_get_*.py tests/test_api_request_handler.py → all pass

PR Tasks

  • PR reference added to issue
  • README updated
  • Unit tests added/updated

@acuanico-tr-galt
Copy link
Collaborator

acuanico-tr-galt commented Mar 12, 2026

Hi @cosmicdreams, thank you for submitting this PR. Once ready, can you point this to release/1.13.4 instead of main? We'll be reviewing the changes before we can merge. Thank you.

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.

[CLI] read/export commands for test plans, suites, and cases

2 participants