示例#1
0
class TestSqliteBasicDBHandler(AbstractDB):
    def setUp(self):
        super(TestSqliteBasicDBHandler, self).setUp()
        self.db = BasicDBHandler(self.session, u"Peer")

    @blocking_call_on_reactor_thread
    def test_size(self):
        size = self.db.size(
        )  # there are 3995 peers in the table, however the upgrade scripts remove 8 superpeers
        assert size == 3987, size
示例#2
0
class TestSqliteBasicDBHandler(AbstractDB):
    @inlineCallbacks
    def setUp(self):
        yield super(TestSqliteBasicDBHandler, self).setUp()
        self.db = BasicDBHandler(self.session, u"Peer")

    def test_size(self):
        size = self.db.size(
        )  # there are 3995 peers in the table, however the upgrade scripts remove 8 superpeers
        assert size == 3987, size
class TestSqliteBasicDBHandler(AbstractDB):

    @inlineCallbacks
    def setUp(self):
        yield super(TestSqliteBasicDBHandler, self).setUp()
        self.db = BasicDBHandler(self.session, u"Peer")

    def test_size(self):
        size = self.db.size()  # there are 3995 peers in the table, however the upgrade scripts remove 8 superpeers
        assert size == 3987, size
class TestSqliteBasicDBHandler(AbstractDB):

    def setUp(self):
        super(TestSqliteBasicDBHandler, self).setUp()
        self.db = BasicDBHandler(self.session, u"Peer")

    @blocking_call_on_reactor_thread
    def test_size(self):
        size = self.db.size()  # there are 3995 peers in the table, however the upgrade scripts remove 8 superpeers
        assert size == 3987, size
 def __init__(self):
     if VideoPlaybackDBHandler.__single is not None:
         raise RuntimeError, "VideoPlaybackDBHandler is singleton"
     BasicDBHandler.__init__(self, SQLiteVideoPlaybackStatsCacheDB.get_instance(), 'playback_event')
 def __init__(self):
     if VideoPlaybackDBHandler.__single is not None:
         raise RuntimeError("VideoPlaybackDBHandler is singleton")
     BasicDBHandler.__init__(self,
                             SQLiteVideoPlaybackStatsCacheDB.get_instance(),
                             'playback_event')
示例#7
0
 def setUp(self):
     yield super(TestSqliteBasicDBHandler, self).setUp()
     self.db = BasicDBHandler(self.session, u"Peer")
 def __init__(self):
     if FriendshipStatisticsDBHandler.__single is not None:
         raise RuntimeError, "FriendshipStatisticsDBHandler is singleton"
     FriendshipStatisticsDBHandler.__single = self
     db = SQLiteFriendshipStatsCacheDB.getInstance()
     BasicDBHandler.__init__(self, db, 'FriendshipStatistics')
示例#9
0
 def __init__(self):
     if SeedingStatsDBHandler.__single is not None:
         raise RuntimeError("SeedingStatDBHandler is singleton")
     SeedingStatsDBHandler.__single = self
     db = SQLiteSeedingStatsCacheDB.getInstance()
     BasicDBHandler.__init__(self, db, 'SeedingStats')
 def setUp(self):
     AbstractDB.setUp(self)
     self.db = BasicDBHandler(self.sqlitedb, 'Peer')
class TestSqliteBasicDBHandler(AbstractDB):

    def setUp(self):
        AbstractDB.setUp(self)
        self.db = BasicDBHandler(self.sqlitedb, 'Peer')

    def test_size(self):
        size = self.db.size()  # there are 3995 peers in the table, however the upgrade scripts remove 8 superpeers
        assert size == 3987, size

    def test_getOne(self):
        ip = self.db.getOne('ip', peer_id=1)
        assert ip == '1.1.1.1', ip

        pid = self.db.getOne('peer_id', ip='1.1.1.1')
        assert pid == 1, pid

        name = self.db.getOne('name', ip='1.1.1.1', port=1)
        assert name == 'Peer 1', name

        name = self.db.getOne('name', ip='68.108.115.221', port=6882)
        assert name == None, name

        tid = self.db.getOne('peer_id', conj='OR', ip='1.1.1.1', name='Peer 1')
        assert tid == 1, tid

        tid = self.db.getOne('peer_id', conj='OR', ip='1.1.1.1', name='asdfasfasfXXXXXXxx...')
        assert tid == 1, tid

        tid = self.db.getOne('peer_id', conj='OR', ip='1.1.1.123', name='Peer 1')
        assert tid == 1, tid

        lbt = self.db.getOne('last_buddycast', peer_id=1)
        assert lbt == 1193379432, lbt

        name, ip, lbt = self.db.getOne(('name', 'ip', 'last_buddycast'), peer_id=1)
        assert name == 'Peer 1' and ip == '1.1.1.1' and lbt == 1193379432, (name, ip, lbt)

        values = self.db.getOne('*', peer_id=1)
        # 03/02/10 Boudewijn: In contrast to the content of the
        # database, the similarity value is not 12.537961593122299 but
        # 0 because it is reset as the database is upgraded.
        results = (1, u'MFIwEAYHKoZIzj0CAQYFK4EEABoDPgAEAAA6SYI4NHxwQ8P7P8QXgWAP+v8SaMVzF5+fSUHdAMrs6NvL5Epe1nCNSdlBHIjNjEiC5iiwSFZhRLsr', u'Peer 1', u'1.1.1.1', 1, None, 2, 0, 0, 0, 1194966306, 1193379769, 1193379432, 1, 1, 0, 0, 0, 0, 0, 0)

        for i in range(len(values)):
            assert values[i] == results[i], (i, values[i], results[i])

    def test_getAll(self):
        ips = self.db.getAll('ip')
        assert len(ips) == 3987, len(ips)

        ips = self.db.getAll('distinct ip')
        assert len(ips) == 256, len(ips)

        ips = self.db.getAll('ip', "ip like '130.%'")
        assert len(ips) == 16, len(ips)

        ids = self.db.getAll('peer_id', 'thumbnail is NULL')
        assert len(ids) == 3987, len(ids)

        ips = self.db.getAll('ip', "ip like '88.%'", port=88, conj='or')
        assert len(ips) == 16, len(ips)

        ips = self.db.getAll('ip', "ip like '88.%'", port=88, order_by='ip')
        assert len(ips) == 1, len(ips)
        assert ips[0][0] == '88.88.88.88', ips[0]

        names = self.db.getAll('name', "ip like '88.%'", order_by='ip', limit=4, offset=1)
        assert len(names) == 4
        assert names[2][0] == 'Peer 856', names
        # select name from Peer where ip like '88.%' and port==7762 order by ip limit 4 offset 3

        ips = self.db.getAll('count(distinct ip), port', group_by='port')
        # select count(distinct ip), port from Peer group by port
        for nip, port in ips:
            if port == 6881:
                assert nip == 2842, nip
                break
示例#12
0
 def __init__(self):
     if FriendshipStatisticsDBHandler.__single is not None:
         raise RuntimeError, "FriendshipStatisticsDBHandler is singleton"
     FriendshipStatisticsDBHandler.__single = self
     db = SQLiteFriendshipStatsCacheDB.getInstance()
     BasicDBHandler.__init__(self, db, 'FriendshipStatistics')
 def __init__(self):
     if SeedingStatsDBHandler.__single is not None:
         raise RuntimeError, "SeedingStatDBHandler is singleton"
     SeedingStatsDBHandler.__single = self
     db = SQLiteSeedingStatsCacheDB.getInstance()
     BasicDBHandler.__init__(self, db, 'SeedingStats')
 def setUp(self):
     yield super(TestSqliteBasicDBHandler, self).setUp()
     self.db = BasicDBHandler(self.session, u"Peer")