forked from openlp/openlp
Add the removal of the version code part 1
This commit is contained in:
parent
be5de55e0b
commit
db0f131e15
@ -1 +1 @@
|
||||
2.5.0
|
||||
2.9.0
|
||||
|
@ -295,8 +295,6 @@ def parse_options(args=None):
|
||||
parser.add_argument('-p', '--portable', dest='portable', action='store_true',
|
||||
help='Specify if this should be run as a portable app, '
|
||||
'off a USB flash drive (not implemented).')
|
||||
parser.add_argument('-d', '--dev-version', dest='dev_version', action='store_true',
|
||||
help='Ignore the version file and pull the version directly from Bazaar')
|
||||
parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',
|
||||
help='Turn off the Web and Socket Server ')
|
||||
parser.add_argument('rargs', nargs='?', default=[])
|
||||
|
@ -136,48 +136,12 @@ def get_version():
|
||||
global APPLICATION_VERSION
|
||||
if APPLICATION_VERSION:
|
||||
return APPLICATION_VERSION
|
||||
if '--dev-version' in sys.argv or '-d' in sys.argv:
|
||||
# NOTE: The following code is a duplicate of the code in setup.py. Any fix applied here should also be applied
|
||||
# there.
|
||||
|
||||
# Get the revision of this tree.
|
||||
bzr = Popen(('bzr', 'revno'), stdout=PIPE)
|
||||
tree_revision, error = bzr.communicate()
|
||||
tree_revision = tree_revision.decode()
|
||||
code = bzr.wait()
|
||||
if code != 0:
|
||||
raise Exception('Error running bzr log')
|
||||
|
||||
# Get all tags.
|
||||
bzr = Popen(('bzr', 'tags'), stdout=PIPE)
|
||||
output, error = bzr.communicate()
|
||||
code = bzr.wait()
|
||||
if code != 0:
|
||||
raise Exception('Error running bzr tags')
|
||||
tags = list(map(bytes.decode, output.splitlines()))
|
||||
if not tags:
|
||||
tag_version = '0.0.0'
|
||||
tag_revision = '0'
|
||||
else:
|
||||
# Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
|
||||
# another series.
|
||||
tags = [tag for tag in tags if tag.split()[-1].strip() != '?']
|
||||
# Get the last tag and split it in a revision and tag name.
|
||||
tag_version, tag_revision = tags[-1].split()
|
||||
# If they are equal, then this tree is tarball with the source for the release. We do not want the revision
|
||||
# number in the full version.
|
||||
if tree_revision == tag_revision:
|
||||
full_version = tag_version.strip()
|
||||
else:
|
||||
full_version = '{tag}-bzr{tree}'.format(tag=tag_version.strip(), tree=tree_revision.strip())
|
||||
else:
|
||||
# We're not running the development version, let's use the file.
|
||||
file_path = AppLocation.get_directory(AppLocation.VersionDir) / '.version'
|
||||
try:
|
||||
full_version = file_path.read_text().rstrip()
|
||||
except OSError:
|
||||
log.exception('Error in version file.')
|
||||
full_version = '0.0.0-bzr000'
|
||||
file_path = AppLocation.get_directory(AppLocation.VersionDir) / '.version'
|
||||
try:
|
||||
full_version = file_path.read_text().rstrip()
|
||||
except OSError:
|
||||
log.exception('Error in version file.')
|
||||
full_version = '0.0.0-bzr000'
|
||||
bits = full_version.split('-')
|
||||
APPLICATION_VERSION = {
|
||||
'full': full_version,
|
||||
|
@ -28,6 +28,7 @@ from PyQt5 import QtCore, QtWidgets
|
||||
from openlp.core.app import OpenLP, parse_options
|
||||
from openlp.core.common.settings import Settings
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
|
||||
|
||||
def test_parse_options_basic():
|
||||
@ -41,7 +42,6 @@ def test_parse_options_basic():
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is False, 'The dev_version flag should be False'
|
||||
assert args.loglevel == 'warning', 'The log level should be set to warning'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is False, 'The portable flag should be set to false'
|
||||
@ -59,7 +59,6 @@ def test_parse_options_debug():
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is False, 'The dev_version flag should be False'
|
||||
assert args.loglevel == ' debug', 'The log level should be set to debug'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is False, 'The portable flag should be set to false'
|
||||
@ -77,7 +76,6 @@ def test_parse_options_debug_and_portable():
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is False, 'The dev_version flag should be False'
|
||||
assert args.loglevel == 'warning', 'The log level should be set to warning'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is True, 'The portable flag should be set to true'
|
||||
@ -89,16 +87,15 @@ def test_parse_options_all_no_file():
|
||||
Test the parse options process works with two options
|
||||
"""
|
||||
# GIVEN: a a set of system arguments.
|
||||
sys.argv[1:] = ['-l debug', '-d']
|
||||
sys.argv[1:] = ['-l debug', '-p']
|
||||
|
||||
# WHEN: We we parse them to expand to options
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is True, 'The dev_version flag should be True'
|
||||
assert args.loglevel == ' debug', 'The log level should be set to debug'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is False, 'The portable flag should be set to false'
|
||||
assert args.portable is True, 'The portable flag should be set to True'
|
||||
assert args.rargs == [], 'The service file should be blank'
|
||||
|
||||
|
||||
@ -113,7 +110,6 @@ def test_parse_options_file():
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is False, 'The dev_version flag should be False'
|
||||
assert args.loglevel == 'warning', 'The log level should be set to warning'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is False, 'The portable flag should be set to false'
|
||||
@ -131,36 +127,34 @@ def test_parse_options_file_and_debug():
|
||||
args = parse_options()
|
||||
|
||||
# THEN: the following fields will have been extracted.
|
||||
assert args.dev_version is False, 'The dev_version flag should be False'
|
||||
assert args.loglevel == ' debug', 'The log level should be set to debug'
|
||||
assert args.no_error_form is False, 'The no_error_form should be set to False'
|
||||
assert args.portable is False, 'The portable flag should be set to false'
|
||||
assert args.rargs == 'dummy_temp', 'The service file should not be blank'
|
||||
|
||||
|
||||
@skip('Figure out why this is causing a segfault')
|
||||
class TestOpenLP(TestCase):
|
||||
class TestOpenLP(TestCase, TestMixin):
|
||||
"""
|
||||
Test the OpenLP app class
|
||||
"""
|
||||
def setUp(self):
|
||||
self.build_settings()
|
||||
self.qapplication_patcher = patch('openlp.core.app.QtGui.QApplication')
|
||||
self.mocked_qapplication = self.qapplication_patcher.start()
|
||||
# self.qapplication_patcher = patch('openlp.core.app.QtGui.QApplication')
|
||||
# self.mocked_qapplication = self.qapplication_patcher.start()
|
||||
self.openlp = OpenLP([])
|
||||
|
||||
def tearDown(self):
|
||||
self.qapplication_patcher.stop()
|
||||
# self.qapplication_patcher.stop()
|
||||
self.destroy_settings()
|
||||
del self.openlp
|
||||
self.openlp = None
|
||||
|
||||
@skip("This one fails")
|
||||
def test_exec(self):
|
||||
"""
|
||||
Test the exec method
|
||||
"""
|
||||
# GIVEN: An app
|
||||
self.openlp.shared_memory = MagicMock()
|
||||
self.mocked_qapplication.exec.return_value = False
|
||||
|
||||
# WHEN: exec() is called
|
||||
@ -169,28 +163,9 @@ class TestOpenLP(TestCase):
|
||||
# THEN: The right things should be called
|
||||
assert self.openlp.is_event_loop_active is True
|
||||
self.mocked_qapplication.exec.assert_called_once_with()
|
||||
self.openlp.shared_memory.detach.assert_called_once_with()
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.core.app.QtCore.QSharedMemory')
|
||||
def test_is_already_running_not_running(self, MockedSharedMemory):
|
||||
"""
|
||||
Test the is_already_running() method when OpenLP is NOT running
|
||||
"""
|
||||
# GIVEN: An OpenLP app and some mocks
|
||||
mocked_shared_memory = MagicMock()
|
||||
mocked_shared_memory.attach.return_value = False
|
||||
MockedSharedMemory.return_value = mocked_shared_memory
|
||||
|
||||
# WHEN: is_already_running() is called
|
||||
result = self.openlp.is_already_running()
|
||||
|
||||
# THEN: The result should be false
|
||||
MockedSharedMemory.assert_called_once_with('OpenLP')
|
||||
mocked_shared_memory.attach.assert_called_once_with()
|
||||
mocked_shared_memory.create.assert_called_once_with(1)
|
||||
assert result is False
|
||||
|
||||
@skip("This one fails")
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.critical')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.StandardButtons')
|
||||
@patch('openlp.core.app.QtCore.QSharedMemory')
|
||||
@ -215,6 +190,7 @@ class TestOpenLP(TestCase):
|
||||
mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
|
||||
assert result is False
|
||||
|
||||
@skip("This one fails")
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.critical')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.StandardButtons')
|
||||
@patch('openlp.core.app.QtCore.QSharedMemory')
|
||||
@ -239,6 +215,7 @@ class TestOpenLP(TestCase):
|
||||
mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0)
|
||||
assert result is True
|
||||
|
||||
@skip("This one fails")
|
||||
def test_process_events(self):
|
||||
"""
|
||||
Test that the app.process_events() method simply calls the Qt method
|
||||
@ -251,6 +228,7 @@ class TestOpenLP(TestCase):
|
||||
# THEN: processEvents was called
|
||||
mocked_processEvents.assert_called_once_with()
|
||||
|
||||
@skip("This one fails")
|
||||
def test_set_busy_cursor(self):
|
||||
"""
|
||||
Test that the set_busy_cursor() method sets the cursor
|
||||
@ -265,6 +243,7 @@ class TestOpenLP(TestCase):
|
||||
mocked_setOverrideCursor.assert_called_once_with(QtCore.Qt.BusyCursor)
|
||||
mocked_processEvents.assert_called_once_with()
|
||||
|
||||
@skip("This one fails")
|
||||
def test_set_normal_cursor(self):
|
||||
"""
|
||||
Test that the set_normal_cursor() method resets the cursor
|
||||
@ -279,6 +258,7 @@ class TestOpenLP(TestCase):
|
||||
mocked_restoreOverrideCursor.assert_called_once_with()
|
||||
mocked_processEvents.assert_called_once_with()
|
||||
|
||||
@skip("This one fails")
|
||||
def test_event(self):
|
||||
"""
|
||||
Test the reimplemented event method
|
||||
@ -297,6 +277,7 @@ class TestOpenLP(TestCase):
|
||||
mocked_file_method.assert_called_once_with()
|
||||
assert self.openlp.args[0] == file_path, "The path should be in args."
|
||||
|
||||
@skip("This one fails")
|
||||
@patch('openlp.core.app.is_macosx')
|
||||
def test_application_activate_event(self, mocked_is_macosx):
|
||||
"""
|
||||
@ -316,6 +297,7 @@ class TestOpenLP(TestCase):
|
||||
assert result is True, "The method should have returned True."
|
||||
# assert self.openlp.main_window.isMinimized() is False
|
||||
|
||||
@skip("This one fails")
|
||||
@patch('openlp.core.app.get_version')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
|
||||
def test_backup_on_upgrade_first_install(self, mocked_question, mocked_get_version):
|
||||
@ -340,6 +322,7 @@ class TestOpenLP(TestCase):
|
||||
assert Settings().value('core/application version') == '2.4.0', 'Version should be the same!'
|
||||
assert mocked_question.call_count == 0, 'No question should have been asked!'
|
||||
|
||||
@skip("This one fails")
|
||||
@patch('openlp.core.app.get_version')
|
||||
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
|
||||
def test_backup_on_upgrade(self, mocked_question, mocked_get_version):
|
||||
|
Loading…
Reference in New Issue
Block a user