mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 04:44:59 +00:00
Test now fetches gsfId and token from env
This *should* fix travis build failing everytime
This commit is contained in:
parent
129d45f19b
commit
3629b232fe
108
test/test.py
108
test/test.py
@ -1,107 +1,99 @@
|
|||||||
from gpapi.googleplay import GooglePlayAPI, RequestError
|
from gpapi.googleplay import GooglePlayAPI, RequestError
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import os
|
||||||
|
|
||||||
ap = argparse.ArgumentParser(description='Test download of expansion files')
|
gsfId = int(os.environ["GPAPI_GSFID"])
|
||||||
ap.add_argument('-e', '--email', dest='email', help='google username')
|
authSubToken = os.environ["GPAPI_TOKEN"]
|
||||||
ap.add_argument('-p', '--password', dest='password', help='google password')
|
|
||||||
|
|
||||||
args = ap.parse_args()
|
server = GooglePlayAPI("it_IT", "Europe/Rome")
|
||||||
|
|
||||||
server = GooglePlayAPI('it_IT', 'Europe/Rome')
|
|
||||||
|
|
||||||
# LOGIN
|
# LOGIN
|
||||||
|
print("\nLogin with ac2dm token and gsfId saved\n")
|
||||||
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')
|
|
||||||
server.login(None, None, gsfId, authSubToken)
|
server.login(None, None, gsfId, authSubToken)
|
||||||
|
|
||||||
# SEARCH
|
# SEARCH
|
||||||
|
print("\nSearch suggestion for \"fir\"\n")
|
||||||
|
print(server.searchSuggest("fir"))
|
||||||
|
|
||||||
print('\nSearch suggestion for "fir"\n')
|
result = server.search("firefox", 34, None)
|
||||||
print(server.searchSuggest('fir'))
|
for doc in result:
|
||||||
|
print("doc: {}".format(doc["docid"]))
|
||||||
result = server.search('firefox', 34, None)
|
for cluster in doc["child"]:
|
||||||
for cluster in result:
|
print("\tcluster: {}".format(cluster["docid"]))
|
||||||
print("cluster: {}".format(cluster.get('docid')))
|
for app in cluster["child"]:
|
||||||
for app in cluster.get('child'):
|
print("\t\tapp: {}".format(app["docid"]))
|
||||||
print(" app: {}".format(app.get('docid')))
|
|
||||||
|
|
||||||
|
|
||||||
# HOME APPS
|
# HOME APPS
|
||||||
|
print("\nFetching apps from play store home\n")
|
||||||
print('\nFetching apps from play store home\n')
|
result = server.home()
|
||||||
result = server.getHomeApps()
|
|
||||||
for cluster in result:
|
for cluster in result:
|
||||||
print("cluster: {}".format(cluster.get('docid')))
|
print("cluster: {}".format(cluster.get("docid")))
|
||||||
for app in cluster.get('child'):
|
for app in cluster.get("child"):
|
||||||
print(" app: {}".format(app.get('docid')))
|
print("\tapp: {}".format(app.get("docid")))
|
||||||
|
|
||||||
|
|
||||||
# DOWNLOAD
|
# DOWNLOAD
|
||||||
docid = 'org.mozilla.focus'
|
docid = "org.mozilla.focus"
|
||||||
server.log(docid)
|
server.log(docid)
|
||||||
print('\nAttempting to download {}\n'.format(docid))
|
print("\nAttempting to download {}\n".format(docid))
|
||||||
fl = server.download(docid)
|
fl = server.download(docid)
|
||||||
with open(docid + '.apk', 'wb') as apk_file:
|
with open(docid + ".apk", "wb") as apk_file:
|
||||||
for chunk in fl.get('file').get('data'):
|
for chunk in fl.get("file").get("data"):
|
||||||
apk_file.write(chunk)
|
apk_file.write(chunk)
|
||||||
print('\nDownload successful\n')
|
print("\nDownload successful\n")
|
||||||
|
|
||||||
# BULK DETAILS
|
# BULK DETAILS
|
||||||
testApps = ['org.mozilla.focus', 'com.non.existing.app']
|
testApps = ["org.mozilla.focus", "com.non.existing.app"]
|
||||||
bulk = server.bulkDetails(testApps)
|
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:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
print('\nResult from bulkDetails for {}\n'.format(testApps[0]))
|
print("\nResult from bulkDetails for {}\n".format(testApps[0]))
|
||||||
print(bulk[0]['docid'])
|
print(bulk[0]["docid"])
|
||||||
|
|
||||||
# DETAILS
|
# DETAILS
|
||||||
print('\nGetting details for %s\n' % testApps[0])
|
print("\nGetting details for %s\n" % testApps[0])
|
||||||
details = server.details(testApps[0])
|
details = server.details(testApps[0])
|
||||||
print(details['title'])
|
print(details["title"])
|
||||||
|
|
||||||
# REVIEWS
|
# REVIEWS
|
||||||
print('\nGetting reviews for %s\n' % testApps[0])
|
print("\nGetting reviews for %s\n" % testApps[0])
|
||||||
revs = server.reviews(testApps[0])
|
revs = server.reviews(testApps[0])
|
||||||
for r in revs:
|
for r in revs:
|
||||||
print("UserId: {0} Vote: {1}".format(
|
print("UserId: {0} Vote: {1}".format(
|
||||||
r['userProfile']['personIdString'],
|
r["userProfile"]["personIdString"],
|
||||||
str(r['starRating'])))
|
str(r["starRating"])))
|
||||||
|
|
||||||
# BROWSE
|
# BROWSE
|
||||||
|
print("\nBrowse play store categories\n")
|
||||||
print('\nBrowse play store categories\n')
|
|
||||||
browse = server.browse()
|
browse = server.browse()
|
||||||
for b in browse:
|
for c in browse.get("category"):
|
||||||
print(b['name'])
|
print(c["name"])
|
||||||
|
|
||||||
sampleCat = browse[0]['unknownCategoryContainer']['categoryIdContainer']['categoryId']
|
sampleCat = browse["category"][0]["unknownCategoryContainer"]["categoryIdContainer"]["categoryId"]
|
||||||
print('\nBrowsing the {} category\n'.format(sampleCat))
|
print("\nBrowsing the {} category\n".format(sampleCat))
|
||||||
browseCat = server.browse(sampleCat)
|
browseCat = server.home(cat=sampleCat)
|
||||||
|
|
||||||
for b in browseCat:
|
for doc in browseCat:
|
||||||
print('%s subcategory with %d apps' % (b['title'], len(b['apps'])))
|
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
|
# LIST
|
||||||
|
cat = "MUSIC_AND_AUDIO"
|
||||||
cat = 'MUSIC_AND_AUDIO'
|
print("\nList %s subcategories\n" % cat)
|
||||||
print('\nList %s subcategories\n' % cat)
|
|
||||||
catList = server.list(cat)
|
catList = server.list(cat)
|
||||||
for c in catList:
|
for c in catList:
|
||||||
print(c)
|
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])
|
appList = server.list(cat, catList[0])
|
||||||
for app in appList:
|
for app in appList:
|
||||||
print(app['docid'])
|
print(app["docid"])
|
||||||
|
Loading…
Reference in New Issue
Block a user