Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityaarakeri/5fc2eb3ffb0a89a03765c8e989c493dd to your computer and use it in GitHub Desktop.
Save adityaarakeri/5fc2eb3ffb0a89a03765c8e989c493dd to your computer and use it in GitHub Desktop.
Sauce REST API via Python
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