Make OpenLP download version files from get.openlp.org; fixes #471

This commit is contained in:
Raoul Snyman 2020-04-23 22:57:12 -07:00
parent 0193ef3f7c
commit 901a41b87b
Signed by: raoul
GPG Key ID: F55BCED79626AE9C
2 changed files with 15 additions and 9 deletions

View File

@ -53,6 +53,10 @@ LIBRARIES = OrderedDict([
('Mako', ('mako',)),
('VLC', ('openlp.core.ui.media.vlcplayer', 'VERSION')),
])
VERSION_BASE_URL = 'https://get.openlp.org/versions/'
VERSION_STABLE = 'version.txt'
VERSION_DEVELOP = 'dev_version.txt'
VERSION_NIGHTLY = 'nightly_version.txt'
class VersionWorker(ThreadWorker):
@ -85,11 +89,13 @@ class VersionWorker(ThreadWorker):
* If a version number's minor version is an even number, it is a stable release.
"""
log.debug('VersionWorker - Start')
download_url = 'https://www.openlp.org/files/version.txt'
download_url = VERSION_BASE_URL
if self.current_version['build']:
download_url = 'https://www.openlp.org/files/nightly_version.txt'
download_url += VERSION_NIGHTLY
elif int(self.current_version['version'].split('.')[1]) % 2 != 0:
download_url = 'https://www.openlp.org/files/dev_version.txt'
download_url += VERSION_DEVELOP
else:
download_url += VERSION_STABLE
headers = {
'User-Agent': 'OpenLP/{version} {system}/{release}; '.format(version=self.current_version['full'],
system=platform.system(),

View File

@ -66,7 +66,7 @@ def test_worker_start(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/version.txt'
expected_download_url = 'https://get.openlp.org/versions/version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.0 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_once_with(expected_download_url, headers=expected_headers)
mock_new_version.emit.assert_called_once_with('2.4.6')
@ -93,7 +93,7 @@ def test_worker_start_fail(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/version.txt'
expected_download_url = 'https://get.openlp.org/versions/version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.0 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_once_with(expected_download_url, headers=expected_headers)
mock_new_version.emit.assert_not_called()
@ -120,7 +120,7 @@ def test_worker_start_dev_version(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/dev_version.txt'
expected_download_url = 'https://get.openlp.org/versions/dev_version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.1.3 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_once_with(expected_download_url, headers=expected_headers)
mock_new_version.emit.assert_called_once_with('2.4.6')
@ -147,7 +147,7 @@ def test_worker_start_nightly_version(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/nightly_version.txt'
expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.1-bzr2345 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_once_with(expected_download_url, headers=expected_headers)
mock_new_version.emit.assert_called_once_with('2.4.6')
@ -174,7 +174,7 @@ def test_worker_empty_response(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/nightly_version.txt'
expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.1-bzr2345 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_once_with(expected_download_url, headers=expected_headers)
assert mock_new_version.emit.call_count == 0
@ -201,7 +201,7 @@ def test_worker_start_connection_error(mock_requests, mock_platform):
worker.start()
# THEN: The check completes and the signal is emitted
expected_download_url = 'https://www.openlp.org/files/version.txt'
expected_download_url = 'https://get.openlp.org/versions/version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.0 Linux/4.12.0-1-amd64; '}
mock_requests.get.assert_called_with(expected_download_url, headers=expected_headers)
assert mock_requests.get.call_count == 3