class TestBasePlugin(unittest.TestCase): def setUp(self): self.base_plugin = BasePlugin(None, [], None, None, get_config(), False, True) self.base_plugin.resp = requests.Response() def test_basic_matcher(self): matcher = BasePlugin.get_basic_matcher("tangerinepulsar.com") self.assertTrue(matcher.match("http://tangerinepulsar.com")) def test_image_header_jpeg(self): self.base_plugin.resp.headers = {"content-type": "image/jpeg"} self.assertTrue(self.base_plugin.valid_image_header()) def test_image_header_jpg(self): self.base_plugin.resp.headers = {"content-type": "image/jpg"} self.assertTrue(self.base_plugin.valid_image_header()) def test_image_header_gif(self): self.base_plugin.resp.headers = {"content-type": "image/gif"} self.assertTrue(self.base_plugin.valid_image_header()) def test_image_header_bmp(self): self.base_plugin.resp.headers = {"content-type": "image/bmp"} self.assertTrue(self.base_plugin.valid_image_header()) def test_image_header_png(self): self.base_plugin.resp.headers = {"content-type": "image/png"} self.assertTrue(self.base_plugin.valid_image_header()) def tearDown(self): pass
def url_matches(url): """ This matches all tumblr urls """ if BasePlugin.get_basic_matcher('tumblr.com').match(url): return True else: return False
def url_matches(url): """ This matches all of imgur """ if BasePlugin.get_basic_matcher('imgur.com').match(url): return True else: return False
def url_matches(url): """ This matches a gfycat link """ if BasePlugin.get_basic_matcher('gfycat.com').match(url): return True else: return False
def url_matches(url): """ This matches 500px photo pages """ if BasePlugin.get_basic_matcher('500px.com').match(url): return True else: return False
def url_matches(url): """ This matches only wallbase user collections. """ if BasePlugin.get_basic_matcher('wallbase.cc').match(url): return True else: return False
def url_matches(url): """ This is matches all deviant art pages """ if BasePlugin.get_basic_matcher('deviantart.com').match(url): return True else: return False
def url_matches(url): """ This matches flickr photo pages """ #QUESTION: is /photos needed here? flickr_pat = BasePlugin.get_basic_matcher('flickr.com/photos') if flickr_pat.match(url): return True else: return False
def setUp(self): self.base_plugin = BasePlugin(None, [], None, None, get_config(), False, True) self.base_plugin.resp = requests.Response()
def test_basic_matcher(self): matcher = BasePlugin.get_basic_matcher("tangerinepulsar.com") self.assertTrue(matcher.match("http://tangerinepulsar.com"))