Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ tb.tests.stop_test(sessionId)
tb.tests.delete_test(sessionId)

# Create a record for a manual / external test result
tb.tests.create_test(name, success=None, status_message=None,
extra=None, build=None)
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()
Comment on lines +88 to +91

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()).

```

## Builds — `tb.build`
Expand Down
12 changes: 10 additions & 2 deletions testingbotclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,17 @@ def get_test(self, sessionId: Union[int, str], skip_fields: Optional[Union[list,
return self.client.get(url)

def create_test(self, name: str, success: Optional[bool] = None, status_message: Optional[str] = None,
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:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"""Create a test record (for logging manual or external test results).

test_environment_id: the ``browser_id`` of the browser/device (from
``tb.information.get_browsers()``) the test ran on. The API rejects
the request without it.
"""
test = {'name': name}
if test_environment_id is not None:
test['test_environment_id'] = test_environment_id
if success is not None:
test['success'] = success
if status_message is not None:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ def test_create_test(self):
'status_message': 'm', 'build': 'b1'}})
self.assertEqual(out, {'success': True})

def test_create_test_with_environment(self):
self.queue(200, {'success': True})
self.client.tests.create_test('manual run', success=True,
test_environment_id=1)
self.assertCall('POST', '/tests', json_body={'test': {
'name': 'manual run', 'test_environment_id': 1,
'success': True}})

def test_update_test_pass(self):
self.queue(200, {'success': True})
ok = self.client.tests.update_test('s', name='n', passed=True,
Expand Down
Loading