diff --git a/README.md b/README.md index e06e075..a9744e6 100644 --- a/README.md +++ b/README.md @@ -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() ``` ## Builds — `tb.build` diff --git a/testingbotclient.py b/testingbotclient.py index 15cb7c0..1afd159 100644 --- a/testingbotclient.py +++ b/testingbotclient.py @@ -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: + """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: diff --git a/tests/test_unit.py b/tests/test_unit.py index d370b13..7220298 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -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,