Move old_client() outside classes
This commit is contained in:
parent
a7e29c56f4
commit
cb18fcb04a
@ -45,15 +45,7 @@ try:
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
|
||||
class SyncCollectionHandler(Syncer):
|
||||
operations = ['meta', 'applyChanges', 'start', 'chunk', 'applyChunk', 'sanityCheck2', 'finish']
|
||||
|
||||
def __init__(self, col):
|
||||
# So that 'server' (the 3rd argument) can't get set
|
||||
Syncer.__init__(self, col)
|
||||
|
||||
@staticmethod
|
||||
def _old_client(cv):
|
||||
def old_client(cv):
|
||||
if not cv:
|
||||
return False
|
||||
|
||||
@ -79,6 +71,15 @@ class SyncCollectionHandler(Syncer):
|
||||
else: # unknown client, assume current version
|
||||
return False
|
||||
|
||||
|
||||
|
||||
class SyncCollectionHandler(Syncer):
|
||||
operations = ['meta', 'applyChanges', 'start', 'chunk', 'applyChunk', 'sanityCheck2', 'finish']
|
||||
|
||||
def __init__(self, col):
|
||||
# So that 'server' (the 3rd argument) can't get set
|
||||
Syncer.__init__(self, col)
|
||||
|
||||
def meta(self):
|
||||
# Make sure the media database is open!
|
||||
if self.col.media.db is None:
|
||||
@ -527,7 +528,7 @@ class SyncApp(object):
|
||||
session.client_version = data['cv']
|
||||
del data['cv']
|
||||
|
||||
if self.session.collection_handler._old_client(session.client_version):
|
||||
if old_client(session.client_version):
|
||||
return Response(status="501") # client needs upgrade
|
||||
|
||||
self.session_manager.save(hkey, session)
|
||||
|
||||
@ -8,6 +8,7 @@ from ankisyncd.sync_app import SyncCollectionHandler
|
||||
from ankisyncd.sync_app import SyncUserSession
|
||||
from ankisyncd.sync_app import SimpleSessionManager
|
||||
from ankisyncd.sync_app import SqliteSessionManager
|
||||
from ankisyncd.sync_app import old_client
|
||||
|
||||
from collection_test_base import CollectionTestBase
|
||||
|
||||
@ -45,12 +46,12 @@ class SyncCollectionHandlerTest(CollectionTestBase):
|
||||
)
|
||||
|
||||
for cv in old:
|
||||
if not self.syncCollectionHandler._old_client(cv):
|
||||
raise AssertionError("_old_client(\"%s\") is False" % cv)
|
||||
if not old_client(cv):
|
||||
raise AssertionError("old_client(\"%s\") is False" % cv)
|
||||
|
||||
for cv in current:
|
||||
if self.syncCollectionHandler._old_client(cv):
|
||||
raise AssertionError("_old_client(\"%s\") is True" % cv)
|
||||
if old_client(cv):
|
||||
raise AssertionError("old_client(\"%s\") is True" % cv)
|
||||
|
||||
def test_meta(self):
|
||||
meta = self.syncCollectionHandler.meta()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user