コード例 #1
0
    def test_collection_sizes(self):
        if not self._is_up():  # no memcached
            return

        fd, dbfile = mkstemp()
        os.close(fd)

        kw = {
            'sqluri': 'sqlite:///%s' % dbfile,
            'use_quota': True,
            'quota_size': 5120,
            'create_tables': True
        }

        try:
            storage = SyncStorage.get(self.fn, **kw)

            # setting the tabs in memcache
            tabs = {
                'mCwylprUEiP5': {
                    'payload': '*' * 1024,
                    'id': 'mCwylprUEiP5',
                    'modified': Decimal('1299142695.76')
                }
            }
            storage.cache.set_tabs(1, tabs)
            size = storage.get_collection_sizes(1)
            self.assertEqual(size['tabs'], 1.)
        finally:
            os.remove(dbfile)
コード例 #2
0
    def test_collection_sizes(self):
        if not self._is_up():  # no memcached
            return

        fd, dbfile = mkstemp()
        os.close(fd)

        kw = {'sqluri': 'sqlite:///%s' % dbfile,
              'use_quota': True,
              'quota_size': 5120,
              'create_tables': True}

        try:
            storage = SyncStorage.get(self.fn, **kw)

            # setting the tabs in memcache
            tabs = {'mCwylprUEiP5':
                    {'payload': '*' * 1024,
                    'id': 'mCwylprUEiP5',
                    'modified': Decimal('1299142695.76')}}
            storage.cache.set_tabs(1, tabs)
            size = storage.get_collection_sizes(1)
            self.assertEqual(size['tabs'], 1.)
        finally:
            os.remove(dbfile)
コード例 #3
0
    def test_register(self):
        class NotAStorage(object):
            pass

        self.assertRaises(TypeError, SyncStorage.register, NotAStorage)
        SyncStorage.register(IAmAValidStorage)
        fqn = 'syncstorage.tests.test_storagebase.IAmAValidStorage'
        self.assert_(isinstance(SyncStorage.get(fqn), IAmAValidStorage))
コード例 #4
0
    def test_register(self):

        class NotAStorage(object):
            pass

        self.assertRaises(TypeError, SyncStorage.register, NotAStorage)
        SyncStorage.register(IAmAValidStorage)
        fqn = 'syncstorage.tests.test_storagebase.IAmAValidStorage'
        self.assert_(isinstance(SyncStorage.get(fqn), IAmAValidStorage))
コード例 #5
0
        def setUp(self):
            fd, self.dbfile = mkstemp()
            os.close(fd)

            kw = {"sqluri": "sqlite:///%s" % self.dbfile, "use_quota": True, "quota_size": 5120, "create_tables": True}

            self.fn = "syncstorage.storage.memcachedsql.MemcachedSQLStorage"

            self.storage = SyncStorage.get(self.fn, **kw)

            # make sure we have the standard collections in place

            for name in ("client", "crypto", "forms", "history"):
                self.storage.set_collection(_UID, name)
コード例 #6
0
        def test_collection_sizes(self):
            if not self._is_up():  # no memcached
                return

            fd, dbfile = mkstemp()
            os.close(fd)

            kw = {"sqluri": "sqlite:///%s" % dbfile, "use_quota": True, "quota_size": 5120, "create_tables": True}

            try:
                storage = SyncStorage.get(self.fn, **kw)

                # setting the tabs in memcache
                tabs = {
                    "mCwylprUEiP5": {"payload": "*" * 1024, "id": "mCwylprUEiP5", "modified": Decimal("1299142695.76")}
                }
                storage.cache.set_tabs(1, tabs)
                size = storage.get_collection_sizes(1)
                self.assertEqual(size["tabs"], 1.0)
            finally:
                os.remove(dbfile)
コード例 #7
0
    def setUp(self):
        if not MEMCACHED:
            raise SkipTest

        # Ensure we have metlog loaded so the timers will work.
        config_file = os.path.join(os.path.dirname(__file__), "sync.conf")
        config = Config(cfgfile=config_file)
        load_and_configure(config, "metlog_loader")

        fd, self.dbfile = mkstemp()
        os.close(fd)

        self.fn = 'syncstorage.storage.memcachedsql.MemcachedSQLStorage'

        kwds = self.STORAGE_CONFIG.copy()
        kwds['sqluri'] = 'sqlite:///%s' % self.dbfile
        self.storage = SyncStorage.get(self.fn, **kwds)

        # make sure we have the standard collections in place

        for name in ('client', 'crypto', 'forms', 'history'):
            self.storage.set_collection(_UID, name)
コード例 #8
0
    def setUp(self):
        if not MEMCACHED:
            raise SkipTest

        # Ensure we have metlog loaded so the timers will work.
        config_file = os.path.join(os.path.dirname(__file__), "sync.conf")
        config = Config(cfgfile=config_file)
        load_and_configure(config, "metlog_loader")

        fd, self.dbfile = mkstemp()
        os.close(fd)

        self.fn = 'syncstorage.storage.memcachedsql.MemcachedSQLStorage'

        kwds = self.STORAGE_CONFIG.copy()
        kwds['sqluri'] = 'sqlite:///%s' % self.dbfile
        self.storage = SyncStorage.get(self.fn, **kwds)

        # make sure we have the standard collections in place

        for name in ('client', 'crypto', 'forms', 'history'):
            self.storage.set_collection(_UID, name)