Repository navigation
create_test: accept test_environment_id (API requires it) - #1
jochen-testingbot wants to merge 1 commit into
Conversation
POST /v1/tests rejects requests without test[test_environment_id] (400 'test[test_environment_id] is missing'), so tb.tests.create_test as documented always failed. Add the optional keyword, a unit test and document it in the README.
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain: the README example uses an undefined browserId, and the client still permits missing required data that the API will reject.
2 open issues
What changed in this PR
Adds support for passing the API-required test_environment_id when creating tests, with unit coverage and README documentation.
Changes:
- Extends
create_test()to accept and serializetest_environment_id. - Adds unit coverage for the new request field.
- Documents how to obtain and use the browser environment ID.
This pull request requires changes.
| File | Summary |
|---|---|
tests/test_unit.py |
Verifies that test_environment_id is included in the create-test request payload. |
testingbotclient.py |
Adds test_environment_id support to create_test(); the current optional default still permits invalid requests without the required field. |
README.md |
Documents the new parameter, but the example uses an undefined browserId variable. |
Review effort: Lite
| extra: Optional[str] = None, build: Optional[str] = None) -> Any: | ||
| """Create a test record (for logging manual or external test results).""" | ||
| extra: Optional[str] = None, build: Optional[str] = None, | ||
| test_environment_id: Optional[Union[int, str]] = None) -> Any: |
There was a problem hiding this comment.
Not changing this. Making test_environment_id positional/required would break existing positional calls (create_test(name, success, status_message, ...)), and a client-side None check would just duplicate the server's validation, which already returns a clear message ('test[test_environment_id] is missing'). The parameter is optional so the signature stays backwards compatible. The docstring and README now say the API needs it.
| tb.tests.create_test(name, test_environment_id=browserId, success=None, | ||
| status_message=None, extra=None, build=None) | ||
| # test_environment_id is required by the API: the `browser_id` of the browser/device | ||
| # the test ran on, from tb.information.get_browsers() |
There was a problem hiding this comment.
Keeping it as a placeholder. This README section lists every method with placeholder arguments (sessionId, buildId, app_url, testId, ...), none of which are defined in the snippet. The comment right below the call says where browserId comes from (the browser_id field of tb.information.get_browsers()).


Part of https://testingbot-team.atlassian.net/browse/TB-1008 (docs audit: run every SDK README snippet).
Problem
Every method in the README works against the live API except one (30/31, checked on both PyPI 0.2.0 and
master):POST /v1/testsrequirestest[test_environment_id], butcreate_testhad no way to send it. The web API reference (config/api_examples/tests.yml) leaves out the Python tab for this reason.Change
create_test(..., test_environment_id=None): optional keyword, so existing calls keep working. It is sent astest.test_environment_idwhen given.browser_idintb.information.get_browsers()).Verification (
python:3.12-slim, package installed from this branch)The full README walkthrough script (31 calls: tests, builds, storage upload/replace/remove of the sample APK, information, screenshots, lab, labsuites, tunnel, team, configuration, user, share link) passes on both PyPI 0.2.0 and this branch, except
create_testwithout the new argument.Release needed: the PyPI page only changes with a new release (0.2.1), which is needs-jochen.