Test now fetches gsfId and token from env

This *should* fix travis build failing everytime
This commit is contained in:
Domenico Iezzi 2018-12-23 22:38:41 +01:00
parent 129d45f19b
commit 3629b232fe
No known key found for this signature in database
GPG Key ID: D8CE73FC9E4393C3

View File

@ -1,107 +1,99 @@
from gpapi.googleplay import GooglePlayAPI, RequestError
import sys
import argparse
import os
ap = argparse.ArgumentParser(description='Test download of expansion files')
ap.add_argument('-e', '--email', dest='email', help='google username')
ap.add_argument('-p', '--password', dest='password', help='google password')
gsfId = int(os.environ["GPAPI_GSFID"])
authSubToken = os.environ["GPAPI_TOKEN"]
args = ap.parse_args()
server = GooglePlayAPI('it_IT', 'Europe/Rome')
server = GooglePlayAPI("it_IT", "Europe/Rome")
# LOGIN
print('\nLogging in with email and password\n')
server.login(args.email, args.password, None, None)
gsfId = server.gsfId
authSubToken = server.authSubToken
print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
server = GooglePlayAPI('it_IT', 'Europe/Rome')
print("\nLogin with ac2dm token and gsfId saved\n")
server.login(None, None, gsfId, authSubToken)
# SEARCH
print("\nSearch suggestion for \"fir\"\n")
print(server.searchSuggest("fir"))
print('\nSearch suggestion for "fir"\n')
print(server.searchSuggest('fir'))
result = server.search('firefox', 34, None)
for cluster in result:
print("cluster: {}".format(cluster.get('docid')))
for app in cluster.get('child'):
print(" app: {}".format(app.get('docid')))
result = server.search("firefox", 34, None)
for doc in result:
print("doc: {}".format(doc["docid"]))
for cluster in doc["child"]:
print("\tcluster: {}".format(cluster["docid"]))
for app in cluster["child"]:
print("\t\tapp: {}".format(app["docid"]))
# HOME APPS
print('\nFetching apps from play store home\n')
result = server.getHomeApps()
print("\nFetching apps from play store home\n")
result = server.home()
for cluster in result:
print("cluster: {}".format(cluster.get('docid')))
for app in cluster.get('child'):
print(" app: {}".format(app.get('docid')))
print("cluster: {}".format(cluster.get("docid")))
for app in cluster.get("child"):
print("\tapp: {}".format(app.get("docid")))
# DOWNLOAD
docid = 'org.mozilla.focus'
docid = "org.mozilla.focus"
server.log(docid)
print('\nAttempting to download {}\n'.format(docid))
print("\nAttempting to download {}\n".format(docid))
fl = server.download(docid)
with open(docid + '.apk', 'wb') as apk_file:
for chunk in fl.get('file').get('data'):
with open(docid + ".apk", "wb") as apk_file:
for chunk in fl.get("file").get("data"):
apk_file.write(chunk)
print('\nDownload successful\n')
print("\nDownload successful\n")
# BULK DETAILS
testApps = ['org.mozilla.focus', 'com.non.existing.app']
testApps = ["org.mozilla.focus", "com.non.existing.app"]
bulk = server.bulkDetails(testApps)
print('\nTesting behaviour for non-existing apps\n')
print("\nTesting behaviour for non-existing apps\n")
if bulk[1] is not None:
print('bulkDetails should return empty dict for non-existing apps')
print("bulkDetails should return empty dict for non-existing apps")
sys.exit(1)
print('\nResult from bulkDetails for {}\n'.format(testApps[0]))
print(bulk[0]['docid'])
print("\nResult from bulkDetails for {}\n".format(testApps[0]))
print(bulk[0]["docid"])
# DETAILS
print('\nGetting details for %s\n' % testApps[0])
print("\nGetting details for %s\n" % testApps[0])
details = server.details(testApps[0])
print(details['title'])
print(details["title"])
# REVIEWS
print('\nGetting reviews for %s\n' % testApps[0])
print("\nGetting reviews for %s\n" % testApps[0])
revs = server.reviews(testApps[0])
for r in revs:
print("UserId: {0} Vote: {1}".format(
r['userProfile']['personIdString'],
str(r['starRating'])))
r["userProfile"]["personIdString"],
str(r["starRating"])))
# BROWSE
print('\nBrowse play store categories\n')
print("\nBrowse play store categories\n")
browse = server.browse()
for b in browse:
print(b['name'])
for c in browse.get("category"):
print(c["name"])
sampleCat = browse[0]['unknownCategoryContainer']['categoryIdContainer']['categoryId']
print('\nBrowsing the {} category\n'.format(sampleCat))
browseCat = server.browse(sampleCat)
sampleCat = browse["category"][0]["unknownCategoryContainer"]["categoryIdContainer"]["categoryId"]
print("\nBrowsing the {} category\n".format(sampleCat))
browseCat = server.home(cat=sampleCat)
for b in browseCat:
print('%s subcategory with %d apps' % (b['title'], len(b['apps'])))
for doc in browseCat:
print("doc: {}".format(doc["docid"]))
for child in doc["child"]:
print("\tsubcat: {}".format(child["docid"]))
for app in child["child"]:
print("\t\tapp: {}".format(app["docid"]))
# LIST
cat = 'MUSIC_AND_AUDIO'
print('\nList %s subcategories\n' % cat)
cat = "MUSIC_AND_AUDIO"
print("\nList %s subcategories\n" % cat)
catList = server.list(cat)
for c in catList:
print(c)
print('\nList %s apps for %s category\n' % (catList[0], cat))
print("\nList %s apps for %s category\n" % (catList[0], cat))
appList = server.list(cat, catList[0])
for app in appList:
print(app['docid'])
print(app["docid"])