當前位置: 首頁>>代碼示例>>Python>>正文


Python LostFilmTVTracker.can_parse_url方法代碼示例

本文整理匯總了Python中monitorrent.plugins.trackers.lostfilm.LostFilmTVTracker.can_parse_url方法的典型用法代碼示例。如果您正苦於以下問題:Python LostFilmTVTracker.can_parse_url方法的具體用法?Python LostFilmTVTracker.can_parse_url怎麽用?Python LostFilmTVTracker.can_parse_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在monitorrent.plugins.trackers.lostfilm.LostFilmTVTracker的用法示例。


在下文中一共展示了LostFilmTVTracker.can_parse_url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: LostFilmTrackerTest

# 需要導入模塊: from monitorrent.plugins.trackers.lostfilm import LostFilmTVTracker [as 別名]
# 或者: from monitorrent.plugins.trackers.lostfilm.LostFilmTVTracker import can_parse_url [as 別名]
class LostFilmTrackerTest(ReadContentMixin, TestCase):
    def setUp(self):
        self.tracker_settings = TrackerSettings(10)
        self.tracker = LostFilmTVTracker()
        self.tracker.tracker_settings = self.tracker_settings
        super(LostFilmTrackerTest, self).setUp()

    @helper.use_vcr()
    def test_login(self):
        self.tracker.login(helper.real_login, helper.real_password)
        self.assertTrue((self.tracker.c_uid == helper.real_uid) or (self.tracker.c_uid == helper.fake_uid))
        self.assertTrue((self.tracker.c_pass == helper.real_pass) or (self.tracker.c_pass == helper.fake_pass))
        self.assertTrue((self.tracker.c_usess == helper.real_usess) or (self.tracker.c_usess == helper.fake_usess))

    @use_vcr()
    def test_fail_login(self):
        with self.assertRaises(LostFilmTVLoginFailedException) as cm:
            self.tracker.login("admin", "FAKE_PASSWORD")
        self.assertEqual(cm.exception.code, 6)
        self.assertEqual(cm.exception.text, u'incorrect login/password')
        self.assertEqual(cm.exception.message, u'Не удалось войти. Возможно не правильный логин/пароль')

    @helper.use_vcr()
    def test_verify(self):
        tracker = LostFilmTVTracker(helper.real_uid, helper.real_pass, helper.real_usess)
        tracker.tracker_settings = self.tracker_settings
        self.assertTrue(tracker.verify())

    def test_verify_false(self):
        self.assertFalse(self.tracker.verify())

    @use_vcr()
    def test_verify_fail(self):
        tracker = LostFilmTVTracker("457686", '1'*32, '2'*32)
        tracker.tracker_settings = self.tracker_settings
        self.assertFalse(tracker.verify())

    def test_parse_correct_title(self):
        title = LostFilmTVTracker._parse_title(u'Род человеческий (Extant)')
        self.assertEqual(u'Род человеческий', title['name'])
        self.assertEqual(u'Extant', title['original_name'])

    def test_parse_correct_title_strange(self):
        title = LostFilmTVTracker._parse_title(u'Род человеческий')
        self.assertEqual(u'Род человеческий', title['original_name'])

    @data(('http://www.lostfilm.tv/browse.php?cat=236', True),
          ('http://www.lostfilm.tv/my.php', False))
    @unpack
    def test_can_parse_url(self, url, value):
        self.assertEqual(value, self.tracker.can_parse_url(url))

    @use_vcr()
    def test_parse_correct_url(self):
        title = self.tracker.parse_url('http://www.lostfilm.tv/browse.php?cat=236')
        self.assertEqual(u'12 обезьян', title['name'])
        self.assertEqual(u'12 Monkeys', title['original_name'])

    @use_vcr()
    def test_parse_correct_url_issue_22_1(self):
        title = self.tracker.parse_url('http://www.lostfilm.tv/browse.php?cat=114')
        self.assertEqual(u'Дневники вампира', title['name'])
        self.assertEqual(u'The Vampire Diaries', title['original_name'])

    @use_vcr()
    def test_parse_correct_url_issue_22_2(self):
        title = self.tracker.parse_url('http://www.lostfilm.tv/browse.php?cat=160')
        self.assertEqual(u'Гримм', title['name'])
        self.assertEqual(u'Grimm', title['original_name'])

    @use_vcr()
    def test_parse_incorrect_url_1(self):
        url = 'http://www.lostfilm.tv/browse_wrong.php?cat=236'
        self.assertIsNone(self.tracker.parse_url(url))

    @use_vcr()
    def test_parse_incorrect_url_2(self):
        url = 'http://www.lostfilm.tv/browse.php?cat=2'
        resp = self.tracker.parse_url(url)
        self.assertIsNotNone(resp)
        self.assertNotEqual(resp.status_code, 200)

    @use_vcr()
    def test_parse_series(self):
        url = 'http://www.lostfilm.tv/browse.php?cat=160'
        parsed_url = self.tracker.parse_url(url, True)
        self.assertEqual(160, parsed_url['cat'])
        self.assertEqual(u'Гримм', parsed_url['name'])
        self.assertEqual(u'Grimm', parsed_url['original_name'])
        self.assertEqual(88, len(parsed_url['episodes']))
        self.assertEqual(4, len(parsed_url['complete_seasons']))

    @use_vcr()
    def test_parse_series_without_original_name(self):
        url = 'http://www.lostfilm.tv/browse.php?cat=129'
        parsed_url = self.tracker.parse_url(url, True)
        self.assertEqual(129, parsed_url['cat'])
        self.assertEqual(u'Касл', parsed_url['name'])
        self.assertEqual(u'Castle', parsed_url['original_name'])
        self.assertEqual(119, len(parsed_url['episodes']))
#.........這裏部分代碼省略.........
開發者ID:Avatarchik,項目名稱:monitorrent,代碼行數:103,代碼來源:test_lostfilmtracker.py


注:本文中的monitorrent.plugins.trackers.lostfilm.LostFilmTVTracker.can_parse_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。