forked from openlp/openlp
changed variable and property names for consistency
added test functions for bibles/versereferencelist
This commit is contained in:
parent
e474a3ce7d
commit
cd8f1e29b1
@ -48,7 +48,7 @@ __default_settings__ = {
|
||||
u'bibles/verse layout style': LayoutStyle.VersePerSlide,
|
||||
u'bibles/book name language': LanguageSelection.Bible,
|
||||
u'bibles/display brackets': DisplayStyle.NoBrackets,
|
||||
u'bibles/display verse': True,
|
||||
u'bibles/verse number display': True,
|
||||
u'bibles/display new chapter': False,
|
||||
u'bibles/second bibles': True,
|
||||
u'bibles/advanced bible': u'',
|
||||
|
@ -58,9 +58,9 @@ class BiblesTab(SettingsTab):
|
||||
self.verse_display_group_box.setObjectName(u'verse_display_group_box')
|
||||
self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box)
|
||||
self.verse_display_layout.setObjectName(u'verse_display_layout')
|
||||
self.display_verse_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
||||
self.display_verse_check_box.setObjectName(u'verse_display_check_box')
|
||||
self.verse_display_layout.addRow(self.display_verse_check_box)
|
||||
self.verse_number_display_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
||||
self.verse_number_display_check_box.setObjectName(u'verse_display_check_box')
|
||||
self.verse_display_layout.addRow(self.verse_number_display_check_box)
|
||||
self.new_chapters_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
||||
self.new_chapters_check_box.setObjectName(u'new_chapters_check_box')
|
||||
self.verse_display_layout.addRow(self.new_chapters_check_box)
|
||||
@ -137,7 +137,7 @@ class BiblesTab(SettingsTab):
|
||||
self.left_layout.addStretch()
|
||||
self.right_layout.addStretch()
|
||||
# Signals and slots
|
||||
self.display_verse_check_box.stateChanged.connect(self.on_display_verse_check_box_changed)
|
||||
self.verse_number_display_check_box.stateChanged.connect(self.on_verse_number_display_check_box_changed)
|
||||
self.new_chapters_check_box.stateChanged.connect(self.on_new_chapters_check_box_changed)
|
||||
self.display_style_combo_box.activated.connect(self.on_display_style_combo_box_changed)
|
||||
self.bible_theme_combo_box.activated.connect(self.on_bible_theme_combo_box_changed)
|
||||
@ -160,7 +160,7 @@ class BiblesTab(SettingsTab):
|
||||
|
||||
def retranslateUi(self):
|
||||
self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display'))
|
||||
self.display_verse_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Display verse numbers'))
|
||||
self.verse_number_display_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Display verse numbers'))
|
||||
self.new_chapters_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers'))
|
||||
self.layout_style_label.setText(UiStrings().LayoutStyle)
|
||||
self.display_style_label.setText(UiStrings().DisplayStyle)
|
||||
@ -213,13 +213,12 @@ class BiblesTab(SettingsTab):
|
||||
def on_language_selection_combo_box_changed(self):
|
||||
self.language_selection = self.language_selection_combo_box.currentIndex()
|
||||
|
||||
def on_display_verse_check_box_changed(self, check_state):
|
||||
self.display_verse = False
|
||||
def on_verse_number_display_check_box_changed(self, check_state):
|
||||
self.verse_number_display = False
|
||||
# We have a set value convert to True/False.
|
||||
if check_state == QtCore.Qt.Checked:
|
||||
self.display_verse = True
|
||||
|
||||
self.check_display_verse()
|
||||
self.verse_number_display = True
|
||||
self.check_verse_number_display()
|
||||
|
||||
def on_new_chapters_check_box_changed(self, check_state):
|
||||
self.show_new_chapters = False
|
||||
@ -312,14 +311,14 @@ class BiblesTab(SettingsTab):
|
||||
def load(self):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
self.display_verse = settings.value(u'display verse')
|
||||
self.verse_number_display = settings.value(u'verse number display')
|
||||
self.show_new_chapters = settings.value(u'display new chapter')
|
||||
self.display_style = settings.value(u'display brackets')
|
||||
self.layout_style = settings.value(u'verse layout style')
|
||||
self.bible_theme = settings.value(u'bible theme')
|
||||
self.second_bibles = settings.value(u'second bibles')
|
||||
self.display_verse_check_box.setChecked(self.display_verse)
|
||||
self.check_display_verse()
|
||||
self.verse_number_display_check_box.setChecked(self.verse_number_display)
|
||||
self.check_verse_number_display()
|
||||
self.new_chapters_check_box.setChecked(self.show_new_chapters)
|
||||
self.display_style_combo_box.setCurrentIndex(self.display_style)
|
||||
self.layout_style_combo_box.setCurrentIndex(self.layout_style)
|
||||
@ -367,7 +366,7 @@ class BiblesTab(SettingsTab):
|
||||
def save(self):
|
||||
settings = Settings()
|
||||
settings.beginGroup(self.settings_section)
|
||||
settings.setValue(u'display verse', self.display_verse)
|
||||
settings.setValue(u'verse number display', self.verse_number_display)
|
||||
settings.setValue(u'display new chapter', self.show_new_chapters)
|
||||
settings.setValue(u'display brackets', self.display_style)
|
||||
settings.setValue(u'verse layout style', self.layout_style)
|
||||
@ -423,11 +422,11 @@ class BiblesTab(SettingsTab):
|
||||
palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
|
||||
return palette
|
||||
|
||||
def check_display_verse(self):
|
||||
def check_verse_number_display(self):
|
||||
"""
|
||||
Enables / Disables verse settings dependent on display_verse
|
||||
Enables / Disables verse settings dependent on verse_number_display
|
||||
"""
|
||||
self.new_chapters_check_box.setEnabled(self.display_verse)
|
||||
self.display_style_label.setEnabled(self.display_verse)
|
||||
self.display_style_combo_box.setEnabled(self.display_verse)
|
||||
self.new_chapters_check_box.setEnabled(self.verse_number_display)
|
||||
self.display_style_label.setEnabled(self.verse_number_display)
|
||||
self.display_style_combo_box.setEnabled(self.verse_number_display)
|
||||
|
||||
|
@ -944,7 +944,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
"""
|
||||
verse_separator = get_reference_separator(u'sep_v_display')
|
||||
|
||||
if self.settings.display_verse:
|
||||
if self.settings.verse_number_display:
|
||||
if not self.settings.show_new_chapters or old_chapter != chapter:
|
||||
verse_text = unicode(chapter) + verse_separator + unicode(verse)
|
||||
else:
|
||||
|
0
tests/functional/openlp_plugins/bibles/__init__.py
Normal file
0
tests/functional/openlp_plugins/bibles/__init__.py
Normal file
@ -0,0 +1,84 @@
|
||||
"""
|
||||
This module contains tests for the versereferencelist submodule of the Bibles plugin.
|
||||
"""
|
||||
|
||||
from unittest import TestCase
|
||||
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
|
||||
|
||||
class TestVerseReferenceList(TestCase):
|
||||
def setUp(self):
|
||||
self.reference_list = VerseReferenceList()
|
||||
|
||||
def add_test(self):
|
||||
"""
|
||||
Test the addition of verses to the list
|
||||
"""
|
||||
|
||||
#GIVEN: book, chapter, verse and version
|
||||
book = u'testBook'
|
||||
chapter = 1
|
||||
verse = 1
|
||||
version = u'testVersion'
|
||||
copyright = u'testCopyright'
|
||||
permission = u'testPermision'
|
||||
|
||||
#WHEN: We add it to the verse list
|
||||
self.reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||
|
||||
#THEN: The entries should be in the first entry of the list
|
||||
self.assertEqual(self.reference_list.current_index, 0, u'The current index should be 0')
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'book'], book, u'The book in first entry should be %s' %book)
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'chapter'], chapter, u'The chapter in first entry should be %u' %chapter)
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'start'], verse, u'The start in first entry should be %u' %verse)
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'version'], version, u'The version in first entry should be %s' %version)
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'end'], verse, u'The end in first entry should be %u' %verse)
|
||||
|
||||
#GIVEN: next verse
|
||||
verse = 2
|
||||
|
||||
#WHEN: We add it to the verse list
|
||||
self.reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||
|
||||
#THEN: The current index should be 0 and the end pointer of the entry should be '2'
|
||||
self.assertEqual(self.reference_list.current_index, 0, u'The current index should be 0')
|
||||
self.assertEqual(self.reference_list.verse_list[0][u'end'], verse, u'The end in first entry should be %u' %verse)
|
||||
|
||||
#GIVEN: a verse in another book
|
||||
book = u'testBook2'
|
||||
chapter = 2
|
||||
verse = 5
|
||||
|
||||
#WHEN: We add it to the verse list
|
||||
self.reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||
|
||||
#THEN: the current index should be 1
|
||||
self.assertEqual(self.reference_list.current_index, 1, u'The current index should be 1')
|
||||
|
||||
def add_version_test(self):
|
||||
"""
|
||||
Test the addition of versions to the list
|
||||
"""
|
||||
#GIVEN: version, copyright and permission
|
||||
version = u'testVersion'
|
||||
copyright = u'testCopyright'
|
||||
permission = u'testPermision'
|
||||
|
||||
|
||||
#WHEN: a not existing version will be added
|
||||
self.reference_list.add_version(version, copyright, permission)
|
||||
|
||||
#THEN: the data will be appended to the list
|
||||
self.assertEqual(self.reference_list.version_list[0], {u'version': version, u'copyright': copyright, u'permission': permission},
|
||||
u'The version data should be appended')
|
||||
|
||||
|
||||
#GIVEN: old length of the array
|
||||
oldLen = self.reference_list.version_list.__len__()
|
||||
|
||||
#WHEN: an existing version will be added
|
||||
self.reference_list.add_version(version, copyright, permission)
|
||||
|
||||
#THEN: the data will not be appended to the list
|
||||
self.assertEqual(self.reference_list.version_list.__len__(), oldLen, u'The version data should not be appended')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user