def read_submission(self, submission: praw.reddit.Submission):
     """Reads a submission from Reddit.
     
     Args:
         submission ('obj': praw.reddit.Submission): A PRAW Submission object.
     
     Returns:
         (urls without tables, (identifiable, anonymous) pair list,
         {'total', 'valid', 'invalid', 'bad_markdown'} dict  of table
         data).
     """
     
     flair = submission.link_flair_text
     tableless_urls = []
     iden_anon_urls = []
     table_data = {'total': 0, 'valid': 0, 'invalid': 0, 'bad_markdown': False}
 
     if self._already_replied(submission.id):
         self.logger.info('Already replied to this submission.')
 
     # Only look at text submissions and with the appropriate flairs
     elif flair in self.pertinent_flairs and submission.is_self:
         self.logger.info(f'CHECKING SUBMISSION: {submission.url}')
     
         # Parse pertinent info from the submission
         tableless_urls, iden_anon_urls, table_data \
             = parse_submission(submission.selftext_html, submission.selftext, self.pcpp_parser)
             
     return tableless_urls, iden_anon_urls, table_data
    def test_parse_submission_same_link_anon_iden(self):
        fp = '../tests/test-posts/same_anon_iden_links.htm'
        text = read_file(fp)
        pcpp = PCPPParser(self.f_handler)

        urls, iden_anon, table = parse_submission(text, '', pcpp)
        self.assertEqual(1, len(urls))
        self.assertEqual(1, len(iden_anon))
        self.assertEqual(0, table['total'])
    def test_parse_submission_table_broken(self):
        fp = '../tests/test-posts/table_broken.htm'
        text = read_file(fp)
        pcpp = PCPPParser(self.f_handler)

        urls, iden_anon, table = parse_submission(text, text, pcpp)
        self.assertEqual(1, len(urls))
        self.assertEqual(0, len(iden_anon))
        self.assertEqual(0, table['total'])
        self.assertTrue(table['bad_markdown'])
    def test_parse_submission_no_elements(self):
        fp = '../tests/test-posts/no_elements.htm'
        text = read_file(fp)
        pcpp = PCPPParser(self.f_handler)

        urls, iden_anon, table = parse_submission(text, '', pcpp)
        self.assertEqual(0, len(urls))
        self.assertEqual(0, len(iden_anon))
        self.assertEqual(0, table['total'])
        self.assertEqual(0, table['invalid'])
        self.assertEqual(0, table['valid'])
        self.assertFalse(table['bad_markdown'])
    def test_parse_submission_three_link_one_unpaired(self):
        fp = '../tests/test-posts/three_link_one_unpaired.htm'
        text = read_file(fp)
        pcpp = PCPPParser(self.f_handler)

        urls, iden_anon, table = parse_submission(text, '', pcpp)
        self.assertEqual(1, len(urls))
        self.assertEqual(1, len(iden_anon))
        self.assertEqual(1, table['total'])
        self.assertEqual(0, table['invalid'])
        self.assertEqual(1, table['valid'])
        self.assertFalse(table['bad_markdown'])