Skip to content

Instantly share code, notes, and snippets.

@LinguineCode
Created July 19, 2018 15:28
Show Gist options
  • Save LinguineCode/2efd76ffba8bc470c1aee075e94a5716 to your computer and use it in GitHub Desktop.
Save LinguineCode/2efd76ffba8bc470c1aee075e94a5716 to your computer and use it in GitHub Desktop.
rainforest
# I hope you appreciate my google-fu, and that I saved time by not writing this from scratch
# It wasn't as easy as just copy/pasting. I had to replace line #2 to make it compatible with recent versions of python.
# Credit goes to: http://codegists.com/snippet/python/letsrevolutionizetesting_challengepy_jschell12_python
import requests
#from urllib.parse import urlparse
from urlparse import urlparse
CHALLENGE_URL = 'https://letsrevolutionizetesting.com/challenge.json'
def contains_prop(prop, json):
if prop in json:
return True
return False
def get_prop(prop, json):
return json[prop]
def get_query_params(url):
return urlparse(url).query
def make_request(challenge_id = None):
payload = {}
json_response = {}
message = None
if(challenge_id):
payload = { 'id': challenge_id }
# make request
r = requests.get(CHALLENGE_URL, payload)
print(r.url)
json_response = r.json()
if(contains_prop('follow', json_response)):
follow = get_prop('follow', json_response)
query_params = get_query_params(follow)
id = query_params.split('=')[1]
return make_request(challenge_id=id)
elif(contains_prop('message', json_response)):
message = get_prop('message', json_response)
return message
if __name__ == '__main__':
print(make_request(challenge_id=None))
#output the following:
#
#https://letsrevolutionizetesting.com/challenge.json
#https://letsrevolutionizetesting.com/challenge.json?id=756775492
#https://letsrevolutionizetesting.com/challenge.json?id=995287801
#https://letsrevolutionizetesting.com/challenge.json?id=572744636
#https://letsrevolutionizetesting.com/challenge.json?id=461736456
#https://letsrevolutionizetesting.com/challenge.json?id=47526821
#https://letsrevolutionizetesting.com/challenge.json?id=80296008
#https://letsrevolutionizetesting.com/challenge.json?id=567724423
#https://letsrevolutionizetesting.com/challenge.json?id=32758300
#https://letsrevolutionizetesting.com/challenge.json?id=580396716
#https://letsrevolutionizetesting.com/challenge.json?id=479167105
#https://letsrevolutionizetesting.com/challenge.json?id=949971757
#https://letsrevolutionizetesting.com/challenge.json?id=861310992
#https://letsrevolutionizetesting.com/challenge.json?id=937651877
#https://letsrevolutionizetesting.com/challenge.json?id=354271637
#https://letsrevolutionizetesting.com/challenge.json?id=705630460
#https://letsrevolutionizetesting.com/challenge.json?id=606216317
#https://letsrevolutionizetesting.com/challenge.json?id=65584552
#https://letsrevolutionizetesting.com/challenge.json?id=831657532
#https://letsrevolutionizetesting.com/challenge.json?id=256000467
#https://letsrevolutionizetesting.com/challenge.json?id=161184211
#https://letsrevolutionizetesting.com/challenge.json?id=208550157
#https://letsrevolutionizetesting.com/challenge.json?id=475613963
#https://letsrevolutionizetesting.com/challenge.json?id=37577102
#https://letsrevolutionizetesting.com/challenge.json?id=724114586
#https://letsrevolutionizetesting.com/challenge.json?id=556333858
#https://letsrevolutionizetesting.com/challenge.json?id=115660865
#https://letsrevolutionizetesting.com/challenge.json?id=716571928
#https://letsrevolutionizetesting.com/challenge.json?id=596834351
#https://letsrevolutionizetesting.com/challenge.json?id=630823541
#https://letsrevolutionizetesting.com/challenge.json?id=652202071
#https://letsrevolutionizetesting.com/challenge.json?id=300716465
#https://letsrevolutionizetesting.com/challenge.json?id=155015675
#https://letsrevolutionizetesting.com/challenge.json?id=135205298
#https://letsrevolutionizetesting.com/challenge.json?id=897873681
#https://letsrevolutionizetesting.com/challenge.json?id=967454426
#https://letsrevolutionizetesting.com/challenge.json?id=71656714
#https://letsrevolutionizetesting.com/challenge.json?id=142868048
#https://letsrevolutionizetesting.com/challenge.json?id=930312428
#https://letsrevolutionizetesting.com/challenge.json?id=197119602
#https://letsrevolutionizetesting.com/challenge.json?id=617265884
#https://letsrevolutionizetesting.com/challenge.json?id=970138205
#https://letsrevolutionizetesting.com/challenge.json?id=201907239
#https://letsrevolutionizetesting.com/challenge.json?id=686630567
#https://letsrevolutionizetesting.com/challenge.json?id=121457796
#https://letsrevolutionizetesting.com/challenge.json?id=488888020
#https://letsrevolutionizetesting.com/challenge.json?id=895507276
#https://letsrevolutionizetesting.com/challenge.json?id=173103113
#https://letsrevolutionizetesting.com/challenge.json?id=803136089
#https://letsrevolutionizetesting.com/challenge.json?id=480810857
#https://letsrevolutionizetesting.com/challenge.json?id=553833934
#https://letsrevolutionizetesting.com/challenge.json?id=801238070
#https://letsrevolutionizetesting.com/challenge.json?id=477183693
#https://letsrevolutionizetesting.com/challenge.json?id=278432362
#https://letsrevolutionizetesting.com/challenge.json?id=75367184
#https://letsrevolutionizetesting.com/challenge.json?id=653620253
#https://letsrevolutionizetesting.com/challenge.json?id=620822263
#https://letsrevolutionizetesting.com/challenge.json?id=368201548
#https://letsrevolutionizetesting.com/challenge.json?id=202982190
#https://letsrevolutionizetesting.com/challenge.json?id=449699507
#https://letsrevolutionizetesting.com/challenge.json?id=469802573
#https://letsrevolutionizetesting.com/challenge.json?id=100196142
#https://letsrevolutionizetesting.com/challenge.json?id=532212727
#https://letsrevolutionizetesting.com/challenge.json?id=180103962
#https://letsrevolutionizetesting.com/challenge.json?id=569247979
#https://letsrevolutionizetesting.com/challenge.json?id=513897475
#https://letsrevolutionizetesting.com/challenge.json?id=911918452
#https://letsrevolutionizetesting.com/challenge.json?id=515668116
#https://letsrevolutionizetesting.com/challenge.json?id=400102864
#https://letsrevolutionizetesting.com/challenge.json?id=598053525
#https://letsrevolutionizetesting.com/challenge.json?id=94928201
#https://letsrevolutionizetesting.com/challenge.json?id=765856838
#https://letsrevolutionizetesting.com/challenge.json?id=529200894
#https://letsrevolutionizetesting.com/challenge.json?id=300886136
#https://letsrevolutionizetesting.com/challenge.json?id=307895327
#https://letsrevolutionizetesting.com/challenge.json?id=530146612
#https://letsrevolutionizetesting.com/challenge.json?id=599920573
#https://letsrevolutionizetesting.com/challenge.json?id=135743876
#https://letsrevolutionizetesting.com/challenge.json?id=454110831
#https://letsrevolutionizetesting.com/challenge.json?id=995478629
#https://letsrevolutionizetesting.com/challenge.json?id=582208015
#https://letsrevolutionizetesting.com/challenge.json?id=811715985
#https://letsrevolutionizetesting.com/challenge.json?id=650890482
#https://letsrevolutionizetesting.com/challenge.json?id=822042114
#https://letsrevolutionizetesting.com/challenge.json?id=582600663
#https://letsrevolutionizetesting.com/challenge.json?id=314974329
#https://letsrevolutionizetesting.com/challenge.json?id=169280871
#https://letsrevolutionizetesting.com/challenge.json?id=5136418
#https://letsrevolutionizetesting.com/challenge.json?id=329594904
#https://letsrevolutionizetesting.com/challenge.json?id=183208047
#https://letsrevolutionizetesting.com/challenge.json?id=627597879
#https://letsrevolutionizetesting.com/challenge.json?id=50576458
#https://letsrevolutionizetesting.com/challenge.json?id=302722799
#https://letsrevolutionizetesting.com/challenge.json?id=936408135
#https://letsrevolutionizetesting.com/challenge.json?id=254043118
#https://letsrevolutionizetesting.com/challenge.json?id=702496729
#https://letsrevolutionizetesting.com/challenge.json?id=94985935
#https://letsrevolutionizetesting.com/challenge.json?id=951438732
#https://letsrevolutionizetesting.com/challenge.json?id=903777032
#https://letsrevolutionizetesting.com/challenge.json?id=503047199
#Congratulations! You've reached the end! You have passed our simple little test and we would love to hear from you. Please save the code you used to a private gist, and fill out the quick application form at https://jobs.lever.co/rainforest. We'll be in touch shortly!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment