Skip to content

Commit a046855

Browse files
committed
update lib + tests
1 parent 84848ae commit a046855

File tree

5 files changed

+326
-125
lines changed

5 files changed

+326
-125
lines changed

README.md

Lines changed: 158 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Build Status](https://travis-ci.org/testingbot/testingbotclient.svg?branch=master)](https://travis-ci.org/testingbot/testingbotclient)
2+
[![PyPI version](https://badge.fury.io/py/testingbotclient.svg)](https://badge.fury.io/py/testingbotclient)
23

34
# testingbotclient
45

@@ -11,91 +12,190 @@ pip install testingbotclient
1112
```
1213

1314
## TestingBot
14-
[TestingBot](https://testingbot.com/) allows you to run your Selenium tests in the cloud.
15-
With access to over 400 different browser combinations, you can run your tests in parallel on their Selenium grid.
15+
[TestingBot](https://testingbot.com/) allows you to run Selenium tests in the cloud.
16+
With access to over +1500 different browser/device combinations, you can run your browser and mobile tests in parallel on the TestingBot Selenium grid.
1617

17-
## Using the client
18+
## Getting Started
1819

1920
```python
2021
import testingbotclient
2122

22-
tb = testingbotclient.TestingBotClient(
23-
'key',
24-
'secret'
25-
)
26-
print tb.tests.update_test("webdriverSessionId", 'my test name', False, 'test failure error')
23+
tb = testingbotclient.TestingBotClient('key', 'secret')
2724
```
2825

2926
It is also possible to use `TESTINGBOT_KEY` and `TESTINGBOT_SECRET` environment variables instead of specifying these in the TestingBotClient constructor. Or use a `~/.testingbot` file with `key:secret`.
3027

31-
## Running tests
3228

33-
This library is only intended to query the TestingBot API.
34-
Below is a simple example which runs a Selenium Webdriver test on TestingBot and reports its name/success state back to TestingBot via this library:
29+
*All API methods can throw these exceptions:*
3530

3631
```python
37-
import unittest
38-
import sys
32+
TestingBotException(errorMessage)
33+
```
3934

40-
from selenium import webdriver
41-
from selenium.webdriver.common.keys import Keys
42-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
43-
from testingbotclient import TestingBotClient
35+
### getBrowsers
36+
Retrieves collection of available browsers
37+
<https://testingbot.com/support/api>
4438

45-
class TestTestingBotClient(unittest.TestCase):
4639

47-
def setUp(self):
48-
desired_cap = {'platform': 'Windows', 'browserName': 'firefox', 'version': 'latest' }
40+
```python
41+
testingbotclient.information.get_browsers()
42+
```
4943

50-
self.driver = webdriver.Remote(
51-
command_executor='http://key:[email protected]/wd/hub',
52-
desired_capabilities=desired_cap)
44+
### updateTest
45+
Update meta-data for a test
46+
<https://testingbot.com/support/api#updatetest>
5347

54-
def test_google_example(self):
55-
self.driver.get("http://www.google.com")
56-
if not "Google" in self.driver.title:
57-
raise Exception("Unable to load google page!")
58-
elem = self.driver.find_element_by_name("q")
59-
elem.send_keys("TestingBot")
60-
elem.submit()
48+
- `String` status_message
49+
- `boolean` success
50+
- `String` build
51+
- `String` name
6152

62-
def tearDown(self):
63-
self.driver.quit()
64-
status = sys.exc_info() == (None, None, None)
65-
tb_client = TestingBotClient('key', 'secret')
66-
tb_client.tests.update_test(self.driver.session_id, self._testMethodName, status)
6753

68-
if __name__ == '__main__':
69-
unittest.main()
54+
```python
55+
testingbotclient.tests.update_test(sessionId, status_message=.., passed=1|0, build=.., name=..)
7056
```
7157

72-
For more information on running Selenium RC/WebDriver tests with Python, please see [Python WebDriver Examples](https://testingbot.com/support/getting-started/python.html)
58+
### stopTest
59+
Stops a running test
60+
<https://testingbot.com/support/api#stoptest>
7361

7462

75-
## More documentation
63+
```python
64+
testingbotclient.tests.stop_test(sessionId)
65+
```
66+
67+
### deleteTest
68+
Deletes a test from TestingBot
69+
<https://testingbot.com/support/api#deletetest>
70+
71+
72+
```python
73+
testingbotclient.tests.delete_test(sessionId)
74+
```
75+
76+
### getTest
77+
Retrieves information regarding a test
78+
<https://testingbot.com/support/api#singletest>
79+
80+
81+
```python
82+
testingbotclient.tests.get_test(sessionId)
83+
```
84+
85+
### getTests
86+
Retrieves a collection of tests
87+
<https://testingbot.com/support/api#tests>
7688

77-
Check out the [TestingBot REST API](https://testingbot.com/support/api) for more information.
7889

79-
## License
90+
```python
91+
testingbotclient.tests.get_tests(offset=0, limit=30)
92+
```
8093

81-
The MIT License (MIT)
94+
### getBuilds
95+
Retrieves a collection of builds
96+
<https://testingbot.com/support/api#builds>
97+
98+
99+
```python
100+
testingbotclient.build.get_builds(offset=0, limit=30)
101+
```
102+
103+
### getTestsForBuild
104+
Retrieves a collection of tests for a specific build
105+
<https://testingbot.com/support/api#singlebuild>
106+
107+
108+
```python
109+
testingbotclient.build.get_tests_for_build(buildId)
110+
```
111+
112+
### getUserConfig
113+
Retrieves information about the current user
114+
<https://testingbot.com/support/api#user>
115+
116+
117+
```python
118+
testingbotclient.user.get_user_information()
119+
```
120+
121+
### getTunnels
122+
Retrieves tunnels for the current user
123+
<https://testingbot.com/support/api#apitunnellist>
124+
125+
126+
```python
127+
testingbotclient.tunnel.get_tunnels()
128+
```
82129

83-
Copyright (c) TestingBot.com
130+
### deleteTunnel
131+
Deletes/stops a specific tunnel for the current user
132+
<https://testingbot.com/support/api#apitunneldelete>
84133

85-
Permission is hereby granted, free of charge, to any person obtaining a copy
86-
of this software and associated documentation files (the "Software"), to deal
87-
in the Software without restriction, including without limitation the rights
88-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
89-
copies of the Software, and to permit persons to whom the Software is
90-
furnished to do so, subject to the following conditions:
91134

92-
The above copyright notice and this permission notice shall be included in
93-
all copies or substantial portions of the Software.
135+
```python
136+
testingbotclient.tunnel.delete_tunnel(sessionId)
137+
```
138+
139+
### uploadToStorage - Local File
140+
Uploads a local file to TestingBot Storage
141+
<https://testingbot.com/support/api#upload>
142+
143+
144+
```python
145+
testingbotclient.storage.upload_local_file(localFilePath)
146+
```
147+
148+
### uploadToStorage - Remote File
149+
Uploads a remote file to TestingBot Storage
150+
<https://testingbot.com/support/api#upload>
151+
152+
153+
```python
154+
testingbotclient.storage.upload_remote_file(localFilePath)
155+
```
156+
157+
### getStorageFile
158+
Retrieves meta-data from a previously stored file
159+
<https://testingbot.com/support/api#uploadfile>
160+
161+
162+
```python
163+
testingbotclient.storage.get_stored_file(appUrl)
164+
```
165+
166+
### getStorageFiles
167+
Retrieves meta-data from previously stored files
168+
<https://testingbot.com/support/api#filelist>
169+
170+
171+
```python
172+
testingbotclient.storage.get_stored_files(appUrl)
173+
```
174+
175+
### deleteStorageFile
176+
Deletes a file previously stored in TestingBot Storage
177+
<https://testingbot.com/support/api#filedelete>
178+
179+
180+
```python
181+
testingbotclient.storage.remove_file(appUrl)
182+
```
183+
184+
### get_share_link
185+
Calculates the authenticationHash necessary to share tests
186+
<https://testingbot.com/support/other/sharing>
187+
188+
189+
```python
190+
testingbotclient.get_share_link(sessionId)
191+
```
192+
193+
## Test
194+
195+
```python
196+
python test_travis.py
197+
```
198+
199+
## More documentation
94200

95-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
98-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
100-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
101-
THE SOFTWARE.
201+
Check out the [TestingBot REST API](https://testingbot.com/support/api) for more information.

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
download_url='http://pypi.python.org/pypi/testingbotclient',
2121
keywords='testingbot selenium testing'.split(),
2222
license='Apache v2.0',
23+
install_requires=[
24+
'requests',
25+
],
2326
classifiers=[
2427
'Development Status :: 4 - Beta',
2528
'Intended Audience :: Developers',

test_travis.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import unittest
3-
3+
import uuid
44
import testingbotclient
55

66
class TestTestingBotClient(unittest.TestCase):
@@ -9,7 +9,52 @@ def setUp(self):
99
self.tb = testingbotclient.TestingBotClient()
1010

1111
def test_get_user_information(self):
12-
self.assertEqual(self.tb.user.get_user_information()['first_name'], "travisbot")
12+
self.assertTrue(self.tb.user.get_user_information()['first_name'])
13+
14+
def test_upload_file(self):
15+
response = self.tb.storage.upload_local_file("./tests/resources/sample.apk")
16+
self.assertTrue(response.get("app_url") != None)
17+
18+
def test_upload_remote_file(self):
19+
response = self.tb.storage.upload_remote_file("https://testingbot.com/appium/sample.apk")
20+
self.assertTrue(response.get("app_url") != None)
21+
22+
def test_upload_and_delete_file(self):
23+
files = self.tb.storage.get_stored_files()
24+
current_count = files.get("meta").get("total")
25+
response = self.tb.storage.upload_local_file("./tests/resources/sample.apk")
26+
app_url = response.get("app_url")
27+
meta_data = self.tb.storage.get_stored_file(app_url)
28+
self.assertEqual(meta_data.get("app_url"), app_url)
29+
30+
files = self.tb.storage.get_stored_files()
31+
self.assertEqual(files.get("meta").get("total"), current_count + 1)
32+
33+
self.tb.storage.remove_file(app_url)
34+
35+
try:
36+
self.tb.storage.get_stored_file(app_url)
37+
except testingbotclient.TestingBotException:
38+
pass
39+
except Exception as e:
40+
self.fail('Unexpected exception raised:', e)
41+
else:
42+
self.fail('ExpectedException not raised')
43+
44+
def test_get_test(self):
45+
sessionId = "6344353dcee24694bf39d5ee5e6e5b11"
46+
test_meta = self.tb.tests.get_test(sessionId)
47+
self.assertEqual(test_meta.get("session_id"), sessionId)
48+
49+
def test_update_test(self):
50+
sessionId = "6344353dcee24694bf39d5ee5e6e5b11"
51+
new_status_message = uuid.uuid4().hex.upper()[0:6]
52+
self.tb.tests.update_test(sessionId, status_message=new_status_message)
53+
test_meta = self.tb.tests.get_test(sessionId)
54+
self.assertEqual(test_meta.get("status_message"), new_status_message)
55+
56+
def test_share_link(self):
57+
self.assertEqual(self.tb.get_share_link("test"), "344ebf07233168c4882adf953a8a8c9b")
1358

1459
if __name__ == '__main__':
1560
unittest.main()

0 commit comments

Comments
 (0)