def test_reproducible_signal_from_play_store(signal_apk): gsfId = int(os.getenv("GPAPI_GSFID", 0)) authSubToken = os.getenv("GPAPI_TOKEN") if not gsfId or not authSubToken: pytest.skip("GPAPI_GSFID or GPAPI_TOKEN missing") from gpapi.googleplay import GooglePlayAPI, RequestError server = GooglePlayAPI() try: server.login(None, None, gsfId, authSubToken) except RequestError as err: pytest.skip("Couldn't login to Play Store: {}".format(err)) try: server.log(SIGNAL_DOCID) except RequestError as err: pytest.skip("Couldn't fetch APK information from Play Store: {}".format(err)) fl = server.download(SIGNAL_DOCID) with open(signal_apk, "wb") as apk_file: for chunk in fl.get("file").get("data"): apk_file.write(chunk) popen = Popen( ["./reproducible-signal.sh", "--play", signal_apk], stdout=PIPE, universal_newlines=True, bufsize=1 ) for line in popen.stdout: current_line = line.rstrip() print(current_line) popen.wait() assert current_line == "APKs match!" assert popen.returncode == 0
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.home() for cluster in result: print("cluster: {}".format(cluster.get("docid"))) for app in cluster.get("child"): print("\tapp: {}".format(app.get("docid"))) # DOWNLOAD docid = "org.mozilla.focus" server.log(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"): apk_file.write(chunk) print("\nDownload successful\n") # BULK DETAILS testApps = ["org.mozilla.focus", "com.non.existing.app"] bulk = server.bulkDetails(testApps) print("\nTesting behaviour for non-existing apps\n") if bulk[1] is not None: print("bulkDetails should return empty dict for non-existing apps") sys.exit(1)