def _get_instructions(args): links = howdoi._get_links(args['query']) if not links: return False question_links = howdoi._get_questions(links) if not question_links: return False only_hyperlinks = args.get('link') star_headers = False answers = [] initial_position = args['pos'] for answer_number in range(args['num_answers']): current_position = answer_number + initial_position args['pos'] = current_position link = howdoi.get_link_at_pos(question_links, current_position) answer = howdoi._get_answer(args, question_links) if not answer: continue answer = howdoi.format_answer(link, answer, star_headers) answers.append(answer) return answers
def test_get_questions(self): links = ['https://stackoverflow.com/questions/tagged/cat', 'http://rads.stackoverflow.com/amzn/click/B007KAZ166', 'https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] expected_output = [ 'https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] actual_output = howdoi._get_questions(links) self.assertSequenceEqual(actual_output, expected_output)
def test_get_questions(self): """ Sprawdzenie odwrotnej operacji. Dla zadanej listy linkow zwroc liste pytan. :return: """ links = ['https://stackoverflow.com/questions/tagged/cat', 'http://rads.stackoverflow.com/amzn/click/B007KAZ166', 'https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] expected_output = ['https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] actual_output = howdoi._get_questions(links) self.assertSequenceEqual(actual_output, expected_output)
def test_get_questions(self): links = ['https://stackoverflow.com/questions/tagged/cat', 'http://rads.stackoverflow.com/amzn/click/B007KAZ166', 'https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] expected_output = ['https://stackoverflow.com/questions/40108569/how-to-get-the-last-line-of-a-file-using-cat-command'] actual_output = howdoi._get_questions(links) self.assertSequenceEqual(actual_output, expected_output)