forked from openlp/openlp
Finish tests
This commit is contained in:
parent
7bcaec2cb3
commit
bc03652cda
|
@ -71,25 +71,25 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
|
||||||
|
|
||||||
def on_split_button_clicked(self):
|
def on_split_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
The split button has been pressed
|
The optional split button has been pressed so we need add the split
|
||||||
"""
|
"""
|
||||||
text = self.verse_text_edit.toPlainText()
|
self._add_splitter_to_text('[---]')
|
||||||
position = self.verse_text_edit.textCursor().position()
|
|
||||||
insert_string = '[---]'
|
|
||||||
if position and text[position - 1] != '\n':
|
|
||||||
insert_string = '\n' + insert_string
|
|
||||||
if position == len(text) or text[position] != '\n':
|
|
||||||
insert_string += '\n'
|
|
||||||
self.verse_text_edit.insertPlainText(insert_string)
|
|
||||||
self.verse_text_edit.setFocus()
|
|
||||||
|
|
||||||
def on_divide_split_button_clicked(self):
|
def on_divide_split_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
The force split button has been pressed so we need add the split
|
The force split button has been pressed so we need add the split
|
||||||
"""
|
"""
|
||||||
|
self._add_splitter_to_text('[--}{--]')
|
||||||
|
|
||||||
|
def _add_splitter_to_text(self, insert_string):
|
||||||
|
"""
|
||||||
|
Add a custom splitter to the song text
|
||||||
|
|
||||||
|
:param insert_string: The string to insert
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
text = self.verse_text_edit.toPlainText()
|
text = self.verse_text_edit.toPlainText()
|
||||||
position = self.verse_text_edit.textCursor().position()
|
position = self.verse_text_edit.textCursor().position()
|
||||||
insert_string = '[--}{--]'
|
|
||||||
if position and text[position - 1] != '\n':
|
if position and text[position - 1] != '\n':
|
||||||
insert_string = '\n' + insert_string
|
insert_string = '\n' + insert_string
|
||||||
if position == len(text) or text[position] != '\n':
|
if position == len(text) or text[position] != '\n':
|
||||||
|
|
|
@ -78,14 +78,25 @@ class TestEditVerseForm(TestCase, TestMixin):
|
||||||
Test that divide adds text at the correct position
|
Test that divide adds text at the correct position
|
||||||
"""
|
"""
|
||||||
# GIVEN some input values
|
# GIVEN some input values
|
||||||
self.edit_verse_form.has_single_verse = True
|
self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=4)
|
||||||
self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=0)
|
self.edit_verse_form.verse_text_edit.setPlainText('Text\n')
|
||||||
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
|
# WHEN the method is called
|
||||||
self.edit_verse_form.on_divide_split_button_clicked()
|
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
|
# THEN the verse number must not be changed
|
||||||
self.assertEqual('--}{--Text', self.edit_verse_form.verse_text_edit.toPlainText(),
|
self.assertEqual('[--}{--]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(),
|
||||||
'The verse number should be 3')
|
'The verse number should be [--}{--]\nText\n')
|
||||||
|
|
||||||
|
def test_on_split_button_clicked(self):
|
||||||
|
"""
|
||||||
|
Test that divide adds text at the correct position
|
||||||
|
"""
|
||||||
|
# GIVEN some input values
|
||||||
|
self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=4)
|
||||||
|
self.edit_verse_form.verse_text_edit.setPlainText('Text\n')
|
||||||
|
|
||||||
|
# WHEN the method is called
|
||||||
|
self.edit_verse_form.on_split_button_clicked()
|
||||||
|
# THEN the verse number must not be changed
|
||||||
|
self.assertEqual('[---]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(),
|
||||||
|
'The verse number should be [---]\nText\n')
|
||||||
|
|
Loading…
Reference in New Issue