-
-
Save adityaarakeri/5fc2eb3ffb0a89a03765c8e989c493dd to your computer and use it in GitHub Desktop.
Sauce REST API via Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import base64 | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
config = {"username": "your-sauce-username", | |
"access-key": "your-sauce-api-key"} | |
base64string = base64.encodestring('%s:%s' % (config['username'], config['access-key']))[:-1] | |
def set_test_status(jobid, passed=True): | |
body_content = json.dumps({"passed": passed}) | |
connection = httplib.HTTPConnection("saucelabs.com") | |
connection.request('PUT', '/rest/v1/%s/jobs/%s' % (config['username'], jobid), | |
body_content, | |
headers={"Authorization": "Basic %s" % base64string}) | |
result = connection.getresponse() | |
return result.status == 200 | |
set_test_status("your-job-id", passed=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment