2017-09-26 20:34:08 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2017-12-29 09:15:48 +00:00
|
|
|
# Copyright (c) 2008-2018 OpenLP Developers #
|
2017-09-26 20:34:08 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 #
|
|
|
|
###############################################################################
|
|
|
|
from tempfile import mkdtemp
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
from openlp.core.api.deploy import deploy_zipfile
|
2017-11-18 11:23:15 +00:00
|
|
|
from openlp.core.common.path import Path, copyfile
|
2017-09-26 20:34:08 +00:00
|
|
|
|
2017-11-18 11:23:15 +00:00
|
|
|
TEST_PATH = (Path(__file__).parent / '..' / '..' / '..' / 'resources').resolve()
|
2017-09-26 20:34:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestRemoteDeploy(TestCase):
|
|
|
|
"""
|
|
|
|
Test the Remote plugin deploy functions
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Setup for tests
|
|
|
|
"""
|
2017-11-18 11:23:15 +00:00
|
|
|
self.app_root_path = Path(mkdtemp())
|
2017-09-26 20:34:08 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""
|
|
|
|
Clean up after tests
|
|
|
|
"""
|
2017-11-18 11:23:15 +00:00
|
|
|
self.app_root_path.rmtree()
|
2017-09-26 20:34:08 +00:00
|
|
|
|
|
|
|
def test_deploy_zipfile(self):
|
|
|
|
"""
|
|
|
|
Remote Deploy tests - test the dummy zip file is processed correctly
|
|
|
|
"""
|
|
|
|
# GIVEN: A new downloaded zip file
|
2017-11-18 11:23:15 +00:00
|
|
|
zip_path = TEST_PATH / 'remotes' / 'site.zip'
|
|
|
|
app_root_path = self.app_root_path / 'site.zip'
|
|
|
|
copyfile(zip_path, app_root_path)
|
|
|
|
|
2017-09-26 20:34:08 +00:00
|
|
|
# WHEN: I process the zipfile
|
2017-11-18 11:23:15 +00:00
|
|
|
deploy_zipfile(self.app_root_path, 'site.zip')
|
2017-09-26 20:34:08 +00:00
|
|
|
|
2017-11-18 11:23:15 +00:00
|
|
|
# THEN: test if www directory has been created
|
2017-12-09 15:21:59 +00:00
|
|
|
assert (self.app_root_path / 'www').is_dir(), 'We should have a www directory'
|