def test_split_strings_are_splitted_and_whitespace_is_removed(): test = "This / is & a , test ; splitting " how_it_should_be = {"This", "is", "a", "test", "splitting"} result = split_strings_to_set({test}) assert how_it_should_be == result
def test_split_strings_are_splitted_and_dots_are_not_splitted(): test = "This Dr. Prof. L. Lala / is & a , test ; splitting " how_it_should_be = { "This Dr. Prof. L. Lala", "is", "a", "test", "splitting" } result = split_strings_to_set({test}) assert how_it_should_be == result
def readers(self): is_book_online = self._fs_monitor.get_book_online show_offline_books = not self._application_settings.hide_offline readers = { book.reader for book in self._model.books if is_book_online(book) or show_offline_books or book.downloaded } return sorted(split_strings_to_set(readers))
def authors(self): is_book_online = self._fs_monitor.get_book_online show_offline_books = not self._application_settings.hide_offline authors = { book.author for book in self._model.books if is_book_online(book) or show_offline_books } return sorted(split_strings_to_set(authors))
def test_readers_contains_every_reader_from_db(): from cozy.model.library import Library from cozy.db.book import Book library = Library() books = Book.select(Book.reader).distinct().order_by(Book.reader) readers_from_db = [book.reader for book in books] readers_from_db = list(split_strings_to_set(set(readers_from_db))) # we cannot assert the same content as the library filters books without chapters assert len(library.readers) > 0 assert library.readers.issubset(readers_from_db)
def test_authors_contains_every_author_from_db(peewee_database): from cozy.model.library import Library from cozy.db.book import Book library = Library(peewee_database) books = Book.select(Book.author).distinct().order_by(Book.author) authors_from_db = [book.author for book in books] authors_from_db = list(split_strings_to_set(set(authors_from_db))) # we cannot assert the same content as the library filters books without chapters assert len(library.authors) > 0 assert library.authors.issubset(authors_from_db)
def readers(self): is_book_online = self._fs_monitor.get_book_online show_offline_books = not self._application_settings.hide_offline swap_author_reader = self._application_settings.swap_author_reader readers = { book.reader if not swap_author_reader else book.author for book in self._model.books if is_book_online(book) or show_offline_books } return sorted(split_strings_to_set(readers))
def test_split_strings_does_nothing_for_non_seperated_element(): test = "This is a nice test. Nothing should be splitted." result = split_strings_to_set({test}) assert {test} == result
def readers(self): readers = {book.reader for book in self.books} readers = split_strings_to_set(readers) return readers
def authors(self): authors = {book.author for book in self.books} authors = split_strings_to_set(authors) return authors