Пример #1
0
    def test_search(self, mocked_settings, *unreferenced_mocks):
        """
        Test that the search method finds the correct results
        """
        # GIVEN: A mocked Settings class which returns a list of Path objects,
        #        and an instance of the PresentationMediaItem
        path_1 = Path('some_dir', 'Impress_file_1')
        path_2 = Path('some_other_dir', 'impress_file_2')
        path_3 = Path('another_dir', 'ppt_file')
        mocked_returned_settings = MagicMock()
        mocked_returned_settings.value.return_value = [path_1, path_2, path_3]
        mocked_settings.return_value = mocked_returned_settings
        media_item = PresentationMediaItem(None, MagicMock(), None)
        media_item.settings_section = ''

        # WHEN: Calling search
        results = media_item.search('IMPRE', False)

        # THEN: The first two results should have been returned
        assert results == [[str(path_1), 'Impress_file_1'], [str(path_2), 'impress_file_2']]