Beispiel #1
0
 def test_is_genre(self):
     tags = Tags()
     tags.append(Tag(name='something'))
     tags.append(Tag(name='something else'))
     book = Book(title='t', author='a', year_published=1, tags=tags)
     self.assertFalse(book.is_genre('som'))
     self.assertTrue(book.is_genre('something'))
Beispiel #2
0
 def should_include(self, book: Book) -> bool:
     if self.get_group_name(book) is None:
         return False
     if book.num_ratings < 1000:
         return False
     if not book.author_similarity:
         return False
     if not book.is_genre('fiction'):
         return False
     if book.word_count < 10000:
         return False
     return True
Beispiel #3
0
 def get_is_usable(self, book: Book) -> None:
     """
     Get if the given book passes the requirements to be
     included in the data.
     """
     if (self.required_genre and not book.is_genre(self.required_genre)
         ) or (self.required_safe_to_use and not book.safe_to_use) or (
             self.required_lang and
             not book.lang == self.required_lang) or (not book.has_content):
         logger.debug('\'%s\' by \'%s\'is not usable', book.title,
                      book.author.name)
         return False
     return True