Esempio n. 1
0
class ParsingTestCase(RemoteTestCase):

    def setUp(self):
        self.torrents = Search(self.url, 'tpb afk')

    def test_items(self):
        self.assertEqual(len(list(self.torrents.items())), 30)
        self.assertEqual(len(list(iter(self.torrents))), 30)

    def test_creation_dates(self):
        """
        Make sure torrents aren't lazily created.
        """
        alpha = time.time()
        # Create torrents
        torrents = self.torrents.items()
        time.sleep(1)
        # If they were lazily evaluated, they would be created now
        diff = next(torrents)._created[1] - alpha
        self.assertTrue(diff > 1)

    def test_torrent_rows(self):
        request = urlopen(str(self.torrents.url))
        document = html.parse(request)
        rows = self.torrents._get_torrent_rows(document.getroot())
        self.assertEqual(len(rows), 30)

    def test_torrent_build(self):
        for torrent in self.torrents.items():
            if torrent.title == 'TPB.AFK.2013.720p.h264-SimonKlose' and\
               torrent.user == 'SimonKlose':
                self.assertEqual(torrent.user_status, 'VIP')
                self.assertTrue(torrent.comments >= 313)
                self.assertEqual(torrent.has_cover, 'Yes')
                break
Esempio n. 2
0
class ParsingTestCase(RemoteTestCase):
    def setUp(self):
        self.torrents = Search(self.url, 'tpb afk')

    def test_items(self):
        self.assertEqual(len(list(self.torrents.items())), 30)
        self.assertEqual(len(list(iter(self.torrents))), 30)

    def test_creation_dates(self):
        """
        Make sure torrents aren't lazily created.
        """
        alpha = time.time()
        # Create torrents
        torrents = self.torrents.items()
        time.sleep(1)
        # If they were lazily evaluated, they would be created now
        diff = next(torrents)._created[1] - alpha
        self.assertTrue(diff > 1)

    def test_torrent_rows(self):
        request = urlopen(str(self.torrents.url))
        document = html.parse(request)
        rows = self.torrents._get_torrent_rows(document.getroot())
        self.assertEqual(len(rows), 30)

    def test_torrent_build(self):
        pass
Esempio n. 3
0
class ParsingTestCase(RemoteTestCase):
    def setUp(self):
        self.torrents = Search(self.url, 'breaking bad')

    def test_items(self):
        self.assertEqual(len(list(self.torrents.items())), 30)
        self.assertEqual(len(list(iter(self.torrents))), 30)

    def test_torrent_rows(self):
        request = urlopen(str(self.torrents.url))
        content = request.read()
        page = BeautifulSoup(content)
        rows = self.torrents._get_torrent_rows(page)
        self.assertEqual(len(rows), 30)

    def test_torrent_build(self):
        pass