2010-02-21 06:20:34 +00:00
|
|
|
from twisted.trial import unittest
|
|
|
|
|
|
|
|
from deluge.ui.tracker_icons import TrackerIcons, TrackerIcon
|
|
|
|
from deluge.log import setupLogger
|
|
|
|
|
|
|
|
# Must come before import common
|
|
|
|
setupLogger("debug", "debug.log")
|
|
|
|
|
|
|
|
import common
|
|
|
|
|
|
|
|
common.set_tmp_config_dir()
|
|
|
|
icons = TrackerIcons()
|
|
|
|
|
|
|
|
class TrackerIconsTestCase(unittest.TestCase):
|
2010-05-04 17:19:54 +00:00
|
|
|
def test_get_deluge_png(self):
|
2010-02-21 06:20:34 +00:00
|
|
|
# Deluge has a png favicon link
|
|
|
|
icon = TrackerIcon("../deluge.png")
|
|
|
|
d = icons.get("deluge-torrent.org")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
|
|
|
|
2010-05-04 17:19:54 +00:00
|
|
|
def test_get_google_ico(self):
|
2010-02-21 06:20:34 +00:00
|
|
|
# Google doesn't have any icon links
|
|
|
|
# So instead we'll grab its favicon.ico
|
|
|
|
icon = TrackerIcon("../google.ico")
|
|
|
|
d = icons.get("www.google.com")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
|
|
|
|
2010-05-04 17:19:54 +00:00
|
|
|
def test_get_google_ico_with_redirect(self):
|
2010-02-21 06:20:34 +00:00
|
|
|
# google.com redirects to www.google.com
|
|
|
|
icon = TrackerIcon("../google.ico")
|
|
|
|
d = icons.get("google.com")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
2010-05-03 20:28:16 +00:00
|
|
|
|
|
|
|
def test_get_ubuntu_ico(self):
|
|
|
|
# ubuntu.com has inline css which causes HTMLParser issues
|
2011-07-05 07:46:01 +00:00
|
|
|
icon = TrackerIcon("../ubuntu.ico")
|
2010-05-03 20:28:16 +00:00
|
|
|
d = icons.get("www.ubuntu.com")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
2010-05-04 17:19:54 +00:00
|
|
|
|
|
|
|
def test_get_openbt_png(self):
|
|
|
|
# openbittorrent.com has an incorrect type (image/gif)
|
|
|
|
icon = TrackerIcon("../openbt.png")
|
|
|
|
d = icons.get("openbittorrent.com")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
2010-05-08 06:24:16 +00:00
|
|
|
|
|
|
|
def test_get_publicbt_ico(self):
|
|
|
|
icon = TrackerIcon("../publicbt.ico")
|
|
|
|
d = icons.get("publicbt.org")
|
|
|
|
d.addCallback(self.assertNotIdentical, None)
|
|
|
|
d.addCallback(self.assertEquals, icon)
|
|
|
|
return d
|
2010-05-09 03:01:46 +00:00
|
|
|
|
|
|
|
def test_get_empty_string_tracker(self):
|
|
|
|
d = icons.get("")
|
2010-07-17 07:11:19 +00:00
|
|
|
d.addCallback(self.assertIdentical, None)
|
2010-05-09 03:01:46 +00:00
|
|
|
return d
|