test.py: fixed wrong method + added progressbar

Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
This commit is contained in:
Domenico Iezzi 2017-10-07 19:22:55 +02:00
parent 73906b104e
commit cb2dc79344

View File

@ -36,7 +36,7 @@ docid = apps[0]['docId']
version = apps[0]['versionCode'] version = apps[0]['versionCode']
print('\nTermux docid is: %s\n' % docid) print('\nTermux docid is: %s\n' % docid)
print('\nAttempting to download %s\n' % docid) print('\nAttempting to download %s\n' % docid)
fl = server.download(docid, version) fl = server.download(docid, version, progress_bar=True)
with open(docid + '.apk', 'wb') as f: with open(docid + '.apk', 'wb') as f:
f.write(fl) f.write(fl)
print('\nDownload successful\n') print('\nDownload successful\n')
@ -46,18 +46,20 @@ with open(docid + '.apk', 'wb') as f:
# Attempting to download Nova Launcher Prime # Attempting to download Nova Launcher Prime
# it should throw an error 'App Not Purchased' # it should throw an error 'App Not Purchased'
print('\nAttempting to download "com.teslacoilsw.launcher.prime"\n')
errorThrown = False errorThrown = False
try: try:
app = server.search('nova launcher prime', 3, None) app = server.search('nova launcher prime', 3, None)
app = filter(lambda x: x['docId'] == 'com.teslacoilsw.launcher.prime', app) app = filter(lambda x: x['docId'] == 'com.teslacoilsw.launcher.prime', app)
app = list(app)[0] app = list(app)[0]
fl = server.download(app['docId'], app['versionCode']) fl = server.delivery(app['docId'], app['versionCode'], progress_bar=True)
with open(docid + '.apk', 'wb') as f: with open(docid + '.apk', 'wb') as f:
f.write(fl) f.write(fl)
print('\nDownload successful\n') print('\nDownload successful\n')
f.close() f.close()
except RequestError as e: except RequestError as e:
errorThrown = True errorThrown = True
print(e)
if not errorThrown: if not errorThrown:
print('Download of previous app should have failed') print('Download of previous app should have failed')