def test_pattern(self): infoq_client = client.InfoQ(cache_enabled=True) summary = next(scrap.get_summaries(infoq_client)) # Nowadays, the /presentations page contains more than 10 entries output = self.run_cmd(self.default_cmd + ["-p", summary['title']]) self.assertEqual(output.count("Id: "), 1)
def test_summaries_max_pages(self): # Check that only one page is fetched count = 0 for summary in scrap.get_summaries(self.iq, filter=scrap.MaxPagesFilter(1)): self.assert_valid_summary(summary) # The number of presentation per page to be updated from time to time # We expect that the number of presentation will never be greater than # this magic number self.assertLessEqual(count, 20) count += 1
def main(self, infoq_client, args): parser = argparse.ArgumentParser(prog="%s %s %s" % (app_name, PresentationModule.name, PresentationModule.PresentationList.name)) parser.add_argument('-m', '--max-pages', type=int, default=10, help='maximum number of pages to fetch (~10 presentations per page)') parser.add_argument('-n', '--max-hits', type=int, default=10, help='maximum number of hits') parser.add_argument('-p', '--pattern', type=str, default=None, help='filter hits according to this pattern') parser.add_argument('-s', '--short', action="store_true", help='short output, only ids are displayed') args = parser.parse_args(args=args) filter = PresentationModule.PresentationList._Filter(pattern=args.pattern, max_hits=args.max_hits, max_pages=args.max_pages) summaries = scrap.get_summaries(infoq_client, filter=filter) if args.short: self.__short_output(summaries) else: self.__standard_output(summaries) return 0
def main(self, infoq_client, args): parser = argparse.ArgumentParser( prog="%s %s %s" % (app_name, PresentationModule.name, PresentationModule.PresentationList.name)) parser.add_argument( '-m', '--max-pages', type=int, default=10, help= 'maximum number of pages to fetch (~10 presentations per page)' ) parser.add_argument('-n', '--max-hits', type=int, default=10, help='maximum number of hits') parser.add_argument('-p', '--pattern', type=str, default=None, help='filter hits according to this pattern') parser.add_argument('-s', '--short', action="store_true", help='short output, only ids are displayed') args = parser.parse_args(args=args) filter = PresentationModule.PresentationList._Filter( pattern=args.pattern, max_hits=args.max_hits, max_pages=args.max_pages) summaries = scrap.get_summaries(infoq_client, filter=filter) if args.short: self.__short_output(summaries) else: self.__standard_output(summaries) return 0
def get_latest_presentation(client): summary = next(scrap.get_summaries(client)) return scrap.Presentation(client, summary['id'])
def test_summaries(self): summaries = scrap.get_summaries(self.iq) for i in range(12): summary = next(summaries) self.assert_valid_summary(summary)