forked from openlp/openlp
Add remotes file checking
This commit is contained in:
parent
a1f9029d25
commit
0d540ae40b
@ -202,7 +202,7 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
|
|||||||
self.themes_url = self.web + self.config.get('themes', 'directory') + '/'
|
self.themes_url = self.web + self.config.get('themes', 'directory') + '/'
|
||||||
self.web_access = True
|
self.web_access = True
|
||||||
except (NoSectionError, NoOptionError, MissingSectionHeaderError):
|
except (NoSectionError, NoOptionError, MissingSectionHeaderError):
|
||||||
log.debug('A problem occured while parsing the downloaded config file')
|
log.debug('A problem occurred while parsing the downloaded config file')
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.update_screen_list_combo()
|
self.update_screen_list_combo()
|
||||||
self.application.process_events()
|
self.application.process_events()
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
from openlp.core.common.httputils import url_get_file
|
||||||
|
|
||||||
|
|
||||||
def deploy_zipfile(zip_file, app_root):
|
def deploy_zipfile(zip_file, app_root):
|
||||||
"""
|
"""
|
||||||
@ -64,6 +66,13 @@ def check_for_previous_deployment(app_root, create=False):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
#def download_and_check():
|
||||||
|
# f = url_get_file(None, 'https://get.openlp.org/webclient', 'download.cfg')
|
||||||
|
# print(f)
|
||||||
|
|
||||||
|
#download_and_check()
|
||||||
|
|
||||||
|
|
||||||
#file_name = "/home/tim/Projects/OpenLP/openlp/remoteweb/deploy.zip"
|
#file_name = "/home/tim/Projects/OpenLP/openlp/remoteweb/deploy.zip"
|
||||||
#app_root = "/home/tim/.openlp/data/remotes/"
|
#app_root = "/home/tim/.openlp/data/remotes/"
|
||||||
|
|
||||||
|
@ -103,6 +103,9 @@ class TestRemoteDeploy(TestCase):
|
|||||||
|
|
||||||
@patch('openlp.plugins.remotes.deploy.open')
|
@patch('openlp.plugins.remotes.deploy.open')
|
||||||
def test_deploy_zipfile(self, mocked_open):
|
def test_deploy_zipfile(self, mocked_open):
|
||||||
|
"""
|
||||||
|
Remote Deploy tests - test the dummy zip file is processed correctly
|
||||||
|
"""
|
||||||
# GIVEN: A new downloaded zip file
|
# GIVEN: A new downloaded zip file
|
||||||
zip_file = os.path.join(TEST_PATH, "remotes", "deploy.zip")
|
zip_file = os.path.join(TEST_PATH, "remotes", "deploy.zip")
|
||||||
# WHEN: I process the zipfile
|
# WHEN: I process the zipfile
|
||||||
|
0
tests/interfaces/openlp_plugins/remotes/__init__.py
Normal file
0
tests/interfaces/openlp_plugins/remotes/__init__.py
Normal file
71
tests/interfaces/openlp_plugins/remotes/test_deploy.py
Normal file
71
tests/interfaces/openlp_plugins/remotes/test_deploy.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2016 OpenLP Developers #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
# Software Foundation; version 2 of the License. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||||
|
# more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License along #
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from openlp.core.common.httputils import url_get_file, get_web_page
|
||||||
|
|
||||||
|
from tests.functional import MagicMock
|
||||||
|
|
||||||
|
|
||||||
|
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources'))
|
||||||
|
|
||||||
|
|
||||||
|
class TestRemoteDeploy(TestCase):
|
||||||
|
"""
|
||||||
|
Test the Remote plugin deploy functions
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""
|
||||||
|
Setup for tests
|
||||||
|
"""
|
||||||
|
self.app_root = mkdtemp()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""
|
||||||
|
Clean up after tests
|
||||||
|
"""
|
||||||
|
shutil.rmtree(self.app_root)
|
||||||
|
|
||||||
|
def test_download_and_check_size(self):
|
||||||
|
"""
|
||||||
|
Remote Deploy tests - Test hosted sites file matches the config file
|
||||||
|
"""
|
||||||
|
# GIVEN: a hosted configuration file
|
||||||
|
user_agent = 'OpenLP/2.4.4'
|
||||||
|
web = 'https://get.openlp.org/webclient/'
|
||||||
|
web_config = get_web_page('{host}{name}'.format(host=web, name='download.cfg'),
|
||||||
|
header=('User-Agent', user_agent))
|
||||||
|
sha = web_config.read().decode('utf-8').split()[0]
|
||||||
|
callback = MagicMock()
|
||||||
|
callback.was_cancelled = False
|
||||||
|
f = os.path.join(self.app_root, 'sites.zip')
|
||||||
|
# WHEN: I download the sites file
|
||||||
|
# THEN: the file will download and match the sha256 from the config file
|
||||||
|
url_get_file(callback, web + 'site.zip', f, sha256=sha)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user