diff --git a/script/test/test_upload.py b/script/test/test_upload.py index 0499a21d375a..a389459ae0ad 100644 --- a/script/test/test_upload.py +++ b/script/test/test_upload.py @@ -32,5 +32,20 @@ def test_returns_none_on_new_draft(self): upload.get_draft(self.repo, 'new') self.assertEquals(upload.get_draft(self.repo, 'test'), None) +class TestYieldBravePackages(unittest.TestCase): + def setUp(self): + self.yield_pkgs_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_yield_pkgs') + + def test_only_returns_dev_darwin_package(self): + upload.PLATFORM = 'darwin' + pkgs = list(upload.yield_brave_packages(os.path.join(self.yield_pkgs_dir, upload.PLATFORM), 'dev', '0.50.8')) + self.assertEquals(pkgs, ['Brave-Browser-Dev.dmg']) + + def test_only_returns_dev_linux_packages(self): + upload.PLATFORM = 'linux' + pkgs = list(upload.yield_brave_packages(os.path.join(self.yield_pkgs_dir, upload.PLATFORM), 'dev', '0.50.8')) + self.assertEquals(sorted(pkgs), sorted(['brave-browser-dev-0.50.8-1.x86_64.rpm', 'brave-browser-dev_0.50.8_amd64.deb'])) + + if __name__ == '__main__': print unittest.main() diff --git a/script/test/test_yield_pkgs/darwin/Brave-Browser-Dev.dmg b/script/test/test_yield_pkgs/darwin/Brave-Browser-Dev.dmg new file mode 100644 index 000000000000..e572e01aee15 --- /dev/null +++ b/script/test/test_yield_pkgs/darwin/Brave-Browser-Dev.dmg @@ -0,0 +1 @@ +dev darwin dmg diff --git a/script/test/test_yield_pkgs/darwin/Brave-Browser-Release.dmg b/script/test/test_yield_pkgs/darwin/Brave-Browser-Release.dmg new file mode 100644 index 000000000000..e0e2cde100b1 --- /dev/null +++ b/script/test/test_yield_pkgs/darwin/Brave-Browser-Release.dmg @@ -0,0 +1 @@ +release darwin dmg diff --git a/script/test/test_yield_pkgs/linux/brave-browser-dev-0.50.8-1.x86_64.rpm b/script/test/test_yield_pkgs/linux/brave-browser-dev-0.50.8-1.x86_64.rpm new file mode 100644 index 000000000000..39658a534e5c --- /dev/null +++ b/script/test/test_yield_pkgs/linux/brave-browser-dev-0.50.8-1.x86_64.rpm @@ -0,0 +1 @@ +mock linux x64 rpm diff --git a/script/test/test_yield_pkgs/linux/brave-browser-dev_0.50.8_amd64.deb b/script/test/test_yield_pkgs/linux/brave-browser-dev_0.50.8_amd64.deb new file mode 100644 index 000000000000..39658a534e5c --- /dev/null +++ b/script/test/test_yield_pkgs/linux/brave-browser-dev_0.50.8_amd64.deb @@ -0,0 +1 @@ +mock linux x64 rpm diff --git a/script/test/test_yield_pkgs/linux/brave-browser-release-0.50.8-1.x86_64.rpm b/script/test/test_yield_pkgs/linux/brave-browser-release-0.50.8-1.x86_64.rpm new file mode 100644 index 000000000000..39658a534e5c --- /dev/null +++ b/script/test/test_yield_pkgs/linux/brave-browser-release-0.50.8-1.x86_64.rpm @@ -0,0 +1 @@ +mock linux x64 rpm diff --git a/script/test/test_yield_pkgs/linux/brave-browser-release_0.50.8_amd64.deb b/script/test/test_yield_pkgs/linux/brave-browser-release_0.50.8_amd64.deb new file mode 100644 index 000000000000..39658a534e5c --- /dev/null +++ b/script/test/test_yield_pkgs/linux/brave-browser-release_0.50.8_amd64.deb @@ -0,0 +1 @@ +mock linux x64 rpm diff --git a/script/upload.py b/script/upload.py index 2b45daf35612..848f9de4e726 100644 --- a/script/upload.py +++ b/script/upload.py @@ -56,8 +56,10 @@ def main(): chromedriver = get_zip_name('chromedriver', get_chromedriver_version()) upload_brave(repo, release, os.path.join(dist_dir(), chromedriver), force=args.force) + pkgs = yield_brave_packages(output_dir(), release_channel(), get_raw_version()) + if PLATFORM == 'darwin': - for pkg in yield_brave_packages(): + for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) elif PLATFORM == 'win32': if get_target_arch() == 'x64': @@ -68,7 +70,7 @@ def main(): 'brave_installer.exe'), 'brave_installer-ia32.exe', force=args.force) else: if get_target_arch() == 'x64': - for pkg in yield_brave_packages(): + for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) else: upload_brave(repo, release, os.path.join(output_dir(), 'brave-i386.rpm'), force=args.force) @@ -86,14 +88,12 @@ def main(): print('[INFO] Finished upload') -def yield_brave_packages(): +def yield_brave_packages(dir, channel, version): # NOTE: mbacchi - before official release this must handle stable release channel which is "" - channel = release_channel() - version = get_raw_version() - for _, _, files in os.walk(output_dir()): + for _, _, files in os.walk(dir): for file in files: if PLATFORM == 'darwin': - if re.match(r'Brave-Browser-' + get_channel_display_name(channel) + r'.*\.dmg$'): + if re.match(r'Brave-Browser-' + channel.capitalize() + r'.*\.dmg$', file): yield file elif PLATFORM == 'linux': if re.match(r'brave-browser-' + channel + '_' + version + r'.*\.deb$', file) \