start of the tests

This commit is contained in:
Tim Bentley 2017-08-09 06:15:10 +01:00
parent bfade0050a
commit 7bcaec2cb3
5 changed files with 28 additions and 12 deletions

View File

@ -208,7 +208,7 @@ def upgrade_db(url, upgrade):
:param upgrade: The python module that contains the upgrade instructions.
"""
if not database_exists(url):
log.warn("Database {db} doesn't exist - skipping upgrade checks".format(db=url))
log.warning("Database {db} doesn't exist - skipping upgrade checks".format(db=url))
return (0, 0)
log.debug('Checking upgrades for DB {db}'.format(db=url))

View File

@ -25,14 +25,13 @@ The duplicate song removal logic for OpenLP.
import logging
import multiprocessing
import os
from PyQt5 import QtCore, QtWidgets
from openlp.core.common import Registry, RegistryProperties, translate
from openlp.core.ui.lib.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib import delete_song
from openlp.plugins.songs.lib.db import Song, MediaFile
from openlp.plugins.songs.lib.db import Song
from openlp.plugins.songs.forms.songreviewwidget import SongReviewWidget
from openlp.plugins.songs.lib.songcompare import songs_probably_equal

View File

@ -42,10 +42,10 @@ class Ui_EditVerseDialog(object):
self.dialog_layout.addWidget(self.verse_text_edit)
self.verse_type_layout = QtWidgets.QHBoxLayout()
self.verse_type_layout.setObjectName('verse_type_layout')
self.force_split_button = QtWidgets.QPushButton(edit_verse_dialog)
self.force_split_button.setIcon(build_icon(':/general/general_add.png'))
self.force_split_button.setObjectName('force_split_button')
self.verse_type_layout.addWidget(self.force_split_button)
self.divide_split_button = QtWidgets.QPushButton(edit_verse_dialog)
self.divide_split_button.setIcon(build_icon(':/general/general_add.png'))
self.divide_split_button.setObjectName('divide_split_button')
self.verse_type_layout.addWidget(self.divide_split_button)
self.split_button = QtWidgets.QPushButton(edit_verse_dialog)
self.split_button.setIcon(build_icon(':/general/general_add.png'))
self.split_button.setObjectName('split_button')
@ -99,9 +99,9 @@ class Ui_EditVerseDialog(object):
self.verse_type_combo_box.setItemText(VerseType.Other, VerseType.translated_names[VerseType.Other])
self.split_button.setText(UiStrings().Split)
self.split_button.setToolTip(UiStrings().SplitToolTip)
self.force_split_button.setText(translate('SongsPlugin.EditVerseForm', '&Divide'))
self.force_split_button.setToolTip(translate('SongsPlugin.EditVerseForm', 'Divide the verse when displayed '
'regardless of the screen size.'))
self.divide_split_button.setText(translate('SongsPlugin.EditVerseForm', '&Divide'))
self.divide_split_button.setToolTip(translate('SongsPlugin.EditVerseForm', 'Divide the verse when displayed '
'regardless of the screen size.'))
self.insert_button.setText(translate('SongsPlugin.EditVerseForm', '&Insert'))
self.insert_button.setToolTip(translate('SongsPlugin.EditVerseForm',
'Split a slide into two by inserting a verse splitter.'))

View File

@ -51,7 +51,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
self.split_button.clicked.connect(self.on_split_button_clicked)
self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed)
self.verse_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed)
self.force_split_button.clicked.connect(self.on_force_split_button_clicked)
self.divide_split_button.clicked.connect(self.on_divide_split_button_clicked)
if Settings().value('songs/enable chords'):
self.transpose_down_button.clicked.connect(self.on_transpose_down_button_clicked)
self.transpose_up_button.clicked.connect(self.on_transpose_up_button_clicked)
@ -83,7 +83,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
self.verse_text_edit.insertPlainText(insert_string)
self.verse_text_edit.setFocus()
def on_force_split_button_clicked(self):
def on_divide_split_button_clicked(self):
"""
The force split button has been pressed so we need add the split
"""

View File

@ -72,3 +72,20 @@ class TestEditVerseForm(TestCase, TestMixin):
# THEN the verse number must not be changed
self.assertEqual(3, self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3')
def test_on_divide_split_button_clicked(self):
"""
Test that divide adds text at the correct position
"""
# GIVEN some input values
self.edit_verse_form.has_single_verse = True
self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=0)
self.edit_verse_form.verse_text_edit.toPlainText = MagicMock(return_value='Text')
self.edit_verse_form.verse_number_box.setValue(3)
# WHEN the method is called
self.edit_verse_form.on_divide_split_button_clicked()
a = self.edit_verse_form.verse_text_edit.toPlainText()
# THEN the verse number must not be changed
self.assertEqual('--}{--Text', self.edit_verse_form.verse_text_edit.toPlainText(),
'The verse number should be 3')