def test_schemes_simialar(self): self.assertTrue(schemes_similar('http', 'http')) self.assertTrue(schemes_similar('https', 'http')) self.assertTrue(schemes_similar('http', 'https')) self.assertTrue(schemes_similar('https', 'https')) self.assertFalse(schemes_similar('ftp', 'http')) self.assertTrue(schemes_similar('email', 'email'))
def test(self, url_info, url_table_record): if url_table_record.inline_level: return True if url_table_record.root_url: top_url_info = URLInfo.parse(url_table_record.root_url) else: top_url_info = url_info if schemes_similar(url_info.scheme, top_url_info.scheme) \ and url_info.hostname == top_url_info.hostname \ and ( url_info.scheme != top_url_info.scheme or url_info.port == top_url_info.port ): return is_subdir(top_url_info.path, url_info.path, trailing_slash=True) return True