def testUpload(self): version = 1337 self.SetUpWorkdir(xml_version=version, gms_lib=True, source_prop=True) status = update.main([ 'upload', '--dry-run', '--skip-git', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should contain license, name = license.sha1 self.assertTrue(os.path.isfile(self.paths.config_license_sha1)) license_sha1 = _GetFileContent(self.paths.config_license_sha1) bucket_license = os.path.join(self.paths.bucket, str(version), license_sha1) self.assertTrue(os.path.isfile(bucket_license)) self.assertEqual(_GetFileContent(bucket_license), self.DEFAULT_LICENSE) # bucket should contain zip, name = zip.sha1 self.assertTrue(os.path.isfile(self.paths.config_zip_sha1)) bucket_zip = os.path.join(self.paths.bucket, str(version), _GetFileContent(self.paths.config_zip_sha1)) self.assertTrue(os.path.isfile(bucket_zip)) # unzip, should contain expected files with zipfile.ZipFile(bucket_zip, "r") as bucket_zip_file: self.assertEqual(bucket_zip_file.namelist(), ['dummy_file', 'res/values/version.xml'])
def testUpload(self): version = '2.3.4' self.SetUpWorkdir( gms_lib=True, config_version=version, source_prop=True) status = update.main([ 'upload', '--dry-run', '--skip-git', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should contain license, name = content from LICENSE.sha1 self.assertTrue(os.path.isfile(self.paths.config_license_sha1)) license_sha1 = _GetFileContent(self.paths.config_license_sha1) bucket_license = os.path.join(self.paths.bucket, version, license_sha1) self.assertTrue(os.path.isfile(bucket_license)) self.assertEqual(_GetFileContent(bucket_license), self.DEFAULT_LICENSE) # bucket should contain zip, name = content from zip.sha1 self.assertTrue(os.path.isfile(self.paths.config_zip_sha1)) bucket_zip = os.path.join(self.paths.bucket, str(version), _GetFileContent(self.paths.config_zip_sha1)) self.assertTrue(os.path.isfile(bucket_zip)) # unzip, should contain expected files with zipfile.ZipFile(bucket_zip, "r") as bucket_zip_file: self.assertEqual(bucket_zip_file.namelist(), ['com/google/android/gms/client/2.3.4/client-2.3.4.aar'])
def testUpload(self): version = 1337 self.SetUpWorkdir( xml_version=version, gms_lib=True, source_prop=True) status = update.main([ 'upload', '--dry-run', '--skip-git', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should contain license, name = license.sha1 self.assertTrue(os.path.isfile(self.paths.config_license_sha1)) license_sha1 = _GetFileContent(self.paths.config_license_sha1) bucket_license = os.path.join(self.paths.bucket, str(version), license_sha1) self.assertTrue(os.path.isfile(bucket_license)) self.assertEqual(_GetFileContent(bucket_license), self.DEFAULT_LICENSE) # bucket should contain zip, name = zip.sha1 self.assertTrue(os.path.isfile(self.paths.config_zip_sha1)) bucket_zip = os.path.join(self.paths.bucket, str(version), _GetFileContent(self.paths.config_zip_sha1)) self.assertTrue(os.path.isfile(bucket_zip)) # unzip, should contain expected files with zipfile.ZipFile(bucket_zip, "r") as bucket_zip_file: self.assertEqual(bucket_zip_file.namelist(), ['dummy_file', 'res/values/version.xml'])
def testUpload(self): version = '2.3.4' self.SetUpWorkdir( gms_lib=True, config_version=version, source_prop=True) status = update.main([ 'upload', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should contain license, name = content from LICENSE.sha1 self.assertTrue(os.path.isfile(self.paths.config_license_sha1)) license_sha1 = _GetFileContent(self.paths.config_license_sha1) bucket_license = os.path.join(self.paths.bucket, version, license_sha1) self.assertTrue(os.path.isfile(bucket_license)) self.assertEqual(_GetFileContent(bucket_license), self.DEFAULT_LICENSE) # bucket should contain zip, name = content from zip.sha1 self.assertTrue(os.path.isfile(self.paths.config_zip_sha1)) bucket_zip = os.path.join(self.paths.bucket, str(version), _GetFileContent(self.paths.config_zip_sha1)) self.assertTrue(os.path.isfile(bucket_zip)) # unzip, should contain expected files with zipfile.ZipFile(bucket_zip, "r") as bucket_zip_file: self.assertEqual(bucket_zip_file.namelist(), ['com/google/android/gms/client/2.3.4/client-2.3.4.aar'])
def testDownloadAcceptedLicense(self): self.SetUpWorkdir(populate_bucket=True, existing_license=self.DEFAULT_LICENSE) # License already accepted, no need to type status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # sdk_root should contain zip contents, zip sha1, license self.assertTrue( os.path.isfile(os.path.join(self.paths.gms_lib, 'dummy_file'))) self.assertTrue(os.path.isfile(self.paths.gms_root_sha1)) self.assertTrue(os.path.isfile(self.paths.gms_root_license)) self.assertEquals(_GetFileContent(self.paths.gms_root_license), self.DEFAULT_LICENSE)
def testDownloadNoAndroidSDK(self): self.SetUpWorkdir( populate_bucket=True, existing_license='Old license') non_existing_sdk_root = os.path.join(self.workdir, 'non_existing_sdk_root') # Should not run, no typing needed status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', non_existing_sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') self.assertFalse(os.path.isdir(non_existing_sdk_root))
def testDownloadAlreadyUpToDate(self): self.SetUpWorkdir( populate_bucket=True, existing_zip_sha1=self.DEFAULT_ZIP_SHA1) status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # there should not be new files downloaded to sdk_root self.assertFalse(os.path.isfile(os.path.join(self.paths.gms_lib, 'dummy_file'))) self.assertFalse(os.path.isfile(self.paths.gms_root_license))
def testDownloadAlreadyUpToDate(self): self.SetUpWorkdir( populate_bucket=True, existing_zip_sha1=self.DEFAULT_ZIP_SHA1) status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # there should not be new files downloaded to sdk_root self.assertFalse(os.path.isfile(os.path.join(self.paths.gms.client_paths[0], 'dummy_file'))) self.assertFalse(os.path.isfile(self.paths.gms.license))
def testDownload(self): self.SetUpWorkdir(populate_bucket=True) with _MockedInput('y'): status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # sdk_root should contain zip contents, zip sha1, license self.assertTrue(os.path.isfile(self.paths.gms.client_paths[0])) self.assertTrue(os.path.isfile(self.paths.gms.lib_zip_sha1)) self.assertTrue(os.path.isfile(self.paths.gms.license)) self.assertEquals(_GetFileContent(self.paths.gms.license), self.DEFAULT_LICENSE)
def testUploadAlreadyLatestVersion(self): self.SetUpWorkdir( xml_version=self.DEFAULT_CONFIG_VERSION, gms_lib=True, source_prop=True) status = update.main([ 'upload', '--dry-run', '--skip-git', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should be empty self.assertFalse(os.listdir(self.paths.bucket)) self.assertFalse(os.path.isfile(self.paths.config_license_sha1)) self.assertFalse(os.path.isfile(self.paths.config_zip_sha1))
def testDownloadRefusedLicense(self): self.SetUpWorkdir( populate_bucket=True, existing_license='Old license') with _MockedInput('n'): status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # there should not be new files downloaded to sdk_root self.assertFalse(os.path.isfile(os.path.join(self.paths.gms_lib, 'dummy_file'))) self.assertEquals(_GetFileContent(self.paths.gms_root_license), 'Old license')
def testDownloadRefusedLicense(self): self.SetUpWorkdir( populate_bucket=True, existing_license='Old license') with _MockedInput('n'): status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # there should not be new files downloaded to sdk_root self.assertFalse(os.path.isfile(os.path.join(self.paths.gms.client_paths[0], 'dummy_file'))) self.assertEquals(_GetFileContent(self.paths.gms.license), 'Old license')
def testDownloadBot(self): self.SetUpWorkdir(populate_bucket=True, bot_env=True) # No need to type 'y' on bots status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # sdk_root should contain zip contents, zip sha1, license self.assertTrue(os.path.isfile(os.path.join(self.paths.gms_lib, 'dummy_file'))) self.assertTrue(os.path.isfile(self.paths.gms_root_sha1)) self.assertTrue(os.path.isfile(self.paths.gms_root_license)) self.assertEquals(_GetFileContent(self.paths.gms_root_license), self.DEFAULT_LICENSE)
def testUploadAlreadyLatestVersion(self): self.SetUpWorkdir(xml_version=self.DEFAULT_CONFIG_VERSION, gms_lib=True, source_prop=True) status = update.main([ 'upload', '--dry-run', '--skip-git', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # bucket should be empty self.assertFalse(os.listdir(self.paths.bucket)) self.assertFalse(os.path.isfile(self.paths.config_license_sha1)) self.assertFalse(os.path.isfile(self.paths.config_zip_sha1))
def testDownloadAcceptedLicense(self): self.SetUpWorkdir( populate_bucket=True, existing_license=self.DEFAULT_LICENSE) # License already accepted, no need to type status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.gms.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # sdk_root should contain zip contents, zip sha1, license self.assertTrue(os.path.isfile(self.paths.gms.client_paths[0])) self.assertTrue(os.path.isfile(self.paths.gms.lib_zip_sha1)) self.assertTrue(os.path.isfile(self.paths.gms.license)) self.assertEquals(_GetFileContent(self.paths.gms.license), self.DEFAULT_LICENSE)
def testDownloadNewLicense(self): self.SetUpWorkdir( populate_bucket=True, existing_license='Old license') with _MockedInput('y'): status = update.main([ 'download', '--dry-run', '--bucket', self.paths.bucket, '--config', self.paths.config_file, '--sdk-root', self.paths.sdk_root, ]) self.assertEqual(status, 0, 'the command should have succeeded.') # sdk_root should contain zip contents, zip sha1, NEW license self.assertTrue(os.path.isfile(os.path.join(self.paths.gms_lib, 'dummy_file'))) self.assertTrue(os.path.isfile(self.paths.gms_root_sha1)) self.assertTrue(os.path.isfile(self.paths.gms_root_license)) self.assertEquals(_GetFileContent(self.paths.gms_root_license), self.DEFAULT_LICENSE)