def test_unpaired_urls_link_after_table(self):
        fp = '../tests/test-posts/link_after_table.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)
        urls = elements['anon']  # No identifiable links
        unpaired_urls = get_urls_with_no_table(urls, elements['tables'])

        self.assertEqual(0, len(unpaired_urls))
    def test_unpaired_urls_iden_anon_same_euro(self):
        fp = '../tests/test-posts/same_anon_iden_links_euro.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)
        all_anon_urls, iden_anon_urls = combine_iden_anon_urls(
            elements['anon'], elements['identifiable'], self.pcpp)

        self.assertEqual(1, len(all_anon_urls))
        self.assertEqual('https://dk.pcpartpicker.com/list/ZqWwj2',
                         all_anon_urls[0])
    def test_unpaired_urls_table_euro(self):
        fp = '../tests/test-posts/table_euro.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)
        all_anon_urls, iden_anon_urls = combine_iden_anon_urls(
            elements['anon'], elements['identifiable'], self.pcpp)
        remaining_urls = get_urls_with_no_table(all_anon_urls,
                                                elements['tables'])

        self.assertEqual(0, len(remaining_urls))
    def test_detect_pcpp_html_iden_view_no_table(self):
        fp = '../tests/test-posts/iden_link_view.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)

        self.assertEqual(1, len(elements['identifiable']))
        expected_iden = 'https://pcpartpicker.com/user/haydenholton/saved/szvVWZ'
        self.assertEqual(expected_iden, elements['identifiable'][0])

        self.assertEqual(0, len(elements['anon']))
        self.assertEqual(0, len(elements['tables']))
    def test_detect_pcpp_html_table_broken(self):
        fp = '../tests/test-posts/table_broken.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)

        self.assertEqual(0, len(elements['identifiable']))

        self.assertEqual(1, len(elements['anon']))
        expected_anon = 'https://pcpartpicker.com/list/9qMcNP'
        self.assertEqual(expected_anon, elements['anon'][0])

        self.assertEqual(0, len(elements['tables']))
    def test_detect_pcpp_html_table_euro(self):
        fp = '../tests/test-posts/table_euro.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)

        self.assertEqual(0, len(elements['identifiable']))

        self.assertEqual(1, len(elements['anon']))
        expected_anon = 'https://be.pcpartpicker.com/list/KytcBc'
        self.assertEqual(expected_anon, elements['anon'][0])

        self.assertEqual(1, len(elements['tables']))
        self.assertTrue(elements['tables'][0].is_valid())
    def test_unpaired_urls_unpaired_url_before_after(self):
        fp = '../tests/test-posts/unpaired_link_before_after.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)

        urls = elements['anon']  # No identifiable links
        self.assertEqual(2, len(urls))

        unpaired_urls = get_urls_with_no_table(urls, elements['tables'])

        expected_url = "https://mx.pcpartpicker.com/list/ZGFq7X"
        self.assertEqual(1, len(unpaired_urls))
        self.assertEqual(expected_url, unpaired_urls[0])
    def test_unpaired_urls_table_iden_only(self):
        fp = '../tests/test-posts/table_iden_only.htm'
        text = read_file(fp)

        elements = detect_pcpp_html_elements(text)
        anon_urls = elements['anon']
        iden_urls = elements['identifiable']
        all_urls, iden_anon_urls = combine_iden_anon_urls(
            anon_urls, iden_urls, self.pcpp)

        self.assertEqual(1, len(all_urls))

        rem_urls = get_urls_with_no_table(all_urls, elements['tables'])

        self.assertEqual(0, len(rem_urls))