Skip to content

test: add unit tests for parse_action and action helpers#410

Open
nankingjing wants to merge 1 commit into
zai-org:mainfrom
nankingjing:test/add-parse-action-tests
Open

test: add unit tests for parse_action and action helpers#410
nankingjing wants to merge 1 commit into
zai-org:mainfrom
nankingjing:test/add-parse-action-tests

Conversation

@nankingjing

Copy link
Copy Markdown

Summary

This PR adds the first unit tests to the repository. Currently there are zero tests despite pytest being listed as a dev dependency in setup.py.

What is tested

tests/test_handler.py covers phone_agent/actions/handler.py:

  • do(...) actions: Tap, Launch, Swipe, Back, Double Tap, Wait, and Tap with a confirmation message
  • Type / Type_Name actions: the special-cased text-extraction path (including spaces, special characters, and Type_Name normalization to Type)
  • finish(...) actions: message extraction
  • Error handling: empty string, unknown action prefix, and garbage input all raise ValueError
  • Helper constructors: do() and finish() metadata injection

All tests are pure and deterministic — no device (ADB/HDC/WDA) or network access required.

Why this matters

parse_action() is the critical bridge between raw model output and device actions. It is completely deterministic and self-contained, making it the ideal starting point for a test suite. These tests lock in the current parsing contract and guard against regressions when the parser is extended (e.g. for GLM-4.6V box tokens or new action types).

Running

pytest tests/test_handler.py -v

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.

1 participant