def test_add_first_verse(self):
        """
        Test the addition of a verse to the empty list
        """
        # GIVEN: an empty list
        reference_list = VerseReferenceList()
        book = 'testBook'
        chapter = 1
        verse = 1
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'

        # WHEN: We add it to the verse list
        reference_list.add(book, chapter, verse, version, copyright_, permission)

        # THEN: The entries should be in the first entry of the list
        self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
        self.assertEqual(reference_list.verse_list[0]['book'], book, 'The book in first entry should be %s' % book)
        self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' %
                                                                           chapter)
        self.assertEqual(reference_list.verse_list[0]['start'], verse, 'The start in first entry should be %u' % verse)
        self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' %
                                                                           version)
        self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse)
Example #2
0
    def test_add_first_verse(self):
        """
        Test the addition of a verse to the empty list
        """
        # GIVEN: an empty list
        reference_list = VerseReferenceList()
        book = 'testBook'
        chapter = 1
        verse = 1
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'

        # WHEN: We add it to the verse list
        reference_list.add(book, chapter, verse, version, copyright_,
                           permission)

        # THEN: The entries should be in the first entry of the list
        self.assertEqual(reference_list.current_index, 0,
                         'The current index should be 0')
        self.assertEqual(reference_list.verse_list[0]['book'], book,
                         'The book in first entry should be %s' % book)
        self.assertEqual(reference_list.verse_list[0]['chapter'], chapter,
                         'The chapter in first entry should be %u' % chapter)
        self.assertEqual(reference_list.verse_list[0]['start'], verse,
                         'The start in first entry should be %u' % verse)
        self.assertEqual(reference_list.verse_list[0]['version'], version,
                         'The version in first entry should be %s' % version)
        self.assertEqual(reference_list.verse_list[0]['end'], verse,
                         'The end in first entry should be %u' % verse)
    def test_add_existing_version(self):
        """
        Test the addition of an existing version to the list
        """
        # GIVEN: version, copyright and permission, added to the version list
        reference_list = VerseReferenceList()
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list.add_version(version, copyright_, permission)

        # WHEN: an existing version will be added
        reference_list.add_version(version, copyright_, permission)

        # THEN: the data will not be appended to the list
        self.assertEqual(len(reference_list.version_list), 1, 'The version data should not be appended')
    def test_add_version(self):
        """
        Test the addition of a version to the list
        """
        # GIVEN: version, copyright and permission
        reference_list = VerseReferenceList()
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'

        # WHEN: a not existing version will be added
        reference_list.add_version(version, copyright_, permission)

        # THEN: the data will be appended to the list
        self.assertEqual(len(reference_list.version_list), 1, 'The version data should be appended')
        self.assertEqual(reference_list.version_list[0],
                         {'version': version, 'copyright': copyright_, 'permission': permission},
                         'The version data should be appended')
Example #5
0
    def add_version_test(self):
        """
        Test the addition of a version to the list
        """
        # GIVEN: version, copyright and permission
        reference_list = VerseReferenceList()
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'

        # WHEN: a not existing version will be added
        reference_list.add_version(version, copyright_, permission)

        # THEN: the data will be appended to the list
        self.assertEqual(len(reference_list.version_list), 1, 'The version data should be appended')
        self.assertEqual(reference_list.version_list[0],
                         {'version': version, 'copyright': copyright_, 'permission': permission},
                         'The version data should be appended')
Example #6
0
    def test_add_another_verse(self):
        """
        Test the addition of a verse in another book
        """
        # GIVEN: 1 line in the list of verses
        book = 'testBook'
        chapter = 1
        verse = 1
        another_book = 'testBook2'
        another_chapter = 2
        another_verse = 5
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list = VerseReferenceList()
        reference_list.add(book, chapter, verse, version, copyright_,
                           permission)

        # WHEN: We add a verse of another book to the verse list
        reference_list.add(another_book, another_chapter, another_verse,
                           version, copyright_, permission)

        # THEN: the current index should be 1
        self.assertEqual(reference_list.current_index, 1,
                         'The current index should be 1')
Example #7
0
    def test_add_next_verse(self):
        """
        Test the addition of the following verse
        """
        # GIVEN: 1 line in the list of verses
        book = 'testBook'
        chapter = 1
        verse = 1
        next_verse = 2
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list = VerseReferenceList()
        reference_list.add(book, chapter, verse, version, copyright_,
                           permission)

        # WHEN: We add the following verse to the verse list
        reference_list.add(book, chapter, next_verse, version, copyright_,
                           permission)

        # THEN: The current index should be 0 and the end pointer of the entry should be '2'
        self.assertEqual(reference_list.current_index, 0,
                         'The current index should be 0')
        self.assertEqual(reference_list.verse_list[0]['end'], next_verse,
                         'The end in first entry should be %u' % next_verse)
    def test_add_another_verse(self):
        """
        Test the addition of a verse in another book
        """
        # GIVEN: 1 line in the list of verses
        book = 'testBook'
        chapter = 1
        verse = 1
        another_book = 'testBook2'
        another_chapter = 2
        another_verse = 5
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list = VerseReferenceList()
        reference_list.add(book, chapter, verse, version, copyright_, permission)

        # WHEN: We add a verse of another book to the verse list
        reference_list.add(another_book, another_chapter, another_verse, version, copyright_, permission)

        # THEN: the current index should be 1
        self.assertEqual(reference_list.current_index, 1, 'The current index should be 1')
    def test_add_next_verse(self):
        """
        Test the addition of the following verse
        """
        # GIVEN: 1 line in the list of verses
        book = 'testBook'
        chapter = 1
        verse = 1
        next_verse = 2
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list = VerseReferenceList()
        reference_list.add(book, chapter, verse, version, copyright_, permission)

        # WHEN: We add the following verse to the verse list
        reference_list.add(book, chapter, next_verse, version, copyright_, permission)

        # THEN: The current index should be 0 and the end pointer of the entry should be '2'
        self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
        self.assertEqual(reference_list.verse_list[0]['end'], next_verse,
                         'The end in first entry should be %u' % next_verse)
Example #10
0
    def add_existing_version_test(self):
        """
        Test the addition of an existing version to the list
        """
        # GIVEN: version, copyright and permission, added to the version list
        reference_list = VerseReferenceList()
        version = 'testVersion'
        copyright_ = 'testCopyright'
        permission = 'testPermission'
        reference_list.add_version(version, copyright_, permission)

        # WHEN: an existing version will be added
        reference_list.add_version(version, copyright_, permission)

        # THEN: the data will not be appended to the list
        self.assertEqual(len(reference_list.version_list), 1, 'The version data should not be appended')
Example #11
0
    def generate_slide_data(self, service_item, *, item=None, remote=False, context=ServiceItemContext.Service,
                            **kwargs):
        """
        Generate the slide data. Needs to be implemented by the plugin.

        :param service_item: The service item to be built on
        :param item: The Song item to be used
        :param remote: Triggered from remote
        :param context: Why is it being generated
        :param kwargs: Consume other unused args specified by the base implementation, but not use by this one.
        """
        log.debug('generating slide data')
        if item:
            items = item
        else:
            items = self.list_view.selectedItems()
        if not items:
            return False
        bible_text = ''
        old_chapter = -1
        raw_slides = []
        verses = VerseReferenceList()
        for bitem in items:
            data = bitem.data(QtCore.Qt.UserRole)
            verses.add(
                data['book'], data['chapter'], data['verse'], data['version'], data['copyright'], data['permissions'])
            verse_text = self.format_verse(old_chapter, data['chapter'], data['verse'])
            # We only support 'Verse Per Slide' when using a scond bible
            if data['second_bible']:
                second_text = self.format_verse(old_chapter, data['chapter'], data['verse'])
                bible_text = '{first_version}{data[text]}\n\n{second_version}{data[second_text]}'\
                    .format(first_version=verse_text, second_version=second_text, data=data)
                raw_slides.append(bible_text.rstrip())
                bible_text = ''
            # If we are 'Verse Per Slide' then create a new slide.
            elif self.settings_tab.layout_style == LayoutStyle.VersePerSlide:
                bible_text = '{first_version}{data[text]}'.format(first_version=verse_text, data=data)
                raw_slides.append(bible_text.rstrip())
                bible_text = ''
            # If we are 'Verse Per Line' then force a new line.
            elif self.settings_tab.layout_style == LayoutStyle.VersePerLine:
                bible_text = '{bible} {verse}{data[text]}\n'.format(bible=bible_text, verse=verse_text, data=data)
            # We have to be 'Continuous'.
            else:
                bible_text = '{bible} {verse}{data[text]}'.format(bible=bible_text, verse=verse_text, data=data)
            bible_text = bible_text.strip(' ')
            old_chapter = data['chapter']
        # Add footer
        service_item.raw_footer.append(verses.format_verses())
        if data['second_bible']:
            verses.add_version(data['second_version'], data['second_copyright'], data['second_permissions'])
        service_item.raw_footer.append(verses.format_versions())
        # If there are no more items we check whether we have to add bible_text.
        if bible_text:
            raw_slides.append(bible_text.lstrip())
        # Service Item: Capabilities
        if self.settings_tab.layout_style == LayoutStyle.Continuous and not data['second_bible']:
            # Split the line but do not replace line breaks in renderer.
            service_item.add_capability(ItemCapabilities.NoLineBreaks)
        service_item.add_capability(ItemCapabilities.CanPreview)
        service_item.add_capability(ItemCapabilities.CanLoop)
        service_item.add_capability(ItemCapabilities.CanWordSplit)
        service_item.add_capability(ItemCapabilities.CanEditTitle)
        # Service Item: Title
        service_item.title = '{verse} {version}'.format(verse=verses.format_verses(), version=verses.format_versions())
        # Service Item: Theme
        if self.settings_tab.bible_theme:
            service_item.theme = self.settings_tab.bible_theme
        for slide in raw_slides:
            service_item.add_from_text(slide)
        return True