Exemple #1
0
    def __iter__(self):
        for batch_of_ids in split_batches(self.ids, self.batch_size):
            self.title_articles_lookup.clear()
            for article in (self.session.query(Article).filter(
                    Article.id.in_(batch_of_ids)).all()):
                self.title_articles_lookup[prepare_title(
                    article.title)].append(article.id)

            for title in self.title_articles_lookup:
                yield title
Exemple #2
0
 def test_prepare_title_handles_empty_titles(self):
     assert prepare_title(None) == ""
Exemple #3
0
 def test_prepare_title_lowercases(self):
     assert prepare_title("UPPER") == "upper"
Exemple #4
0
 def test_prepare_title_replaces_invalid_characters_with_single_space(self):
     assert prepare_title("invalid%&*^˙∆¬stuff") == "invalid stuff"
     assert prepare_title("ba!!!!d3") == "ba d3"
Exemple #5
0
 def test_prepare_title_removes_extra_spaces(self):
     assert prepare_title("extra   spaces       here") == "extra spaces here"
     assert prepare_title("trailing space ") == "trailing space"