diff --git a/openlp/core/version.py b/openlp/core/version.py index 7bc19de4d..8ced4b307 100644 --- a/openlp/core/version.py +++ b/openlp/core/version.py @@ -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(), diff --git a/tests/functional/openlp_core/test_version.py b/tests/functional/openlp_core/test_version.py index ee29a50c7..375017215 100644 --- a/tests/functional/openlp_core/test_version.py +++ b/tests/functional/openlp_core/test_version.py @@ -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