コード例 #1
0
    def test_get_full_sync_manager(self):
        # Get absolute path to development ini file.
        script_dir = os.path.dirname(os.path.realpath(__file__))
        ini_file_path = os.path.join(script_dir, "assets", "test.conf")

        # Create temporary files and dirs the server will use.
        server_paths = helpers.server_utils.create_server_paths()

        config = configparser.ConfigParser()
        config.read(ini_file_path)

        # Use custom files and dirs in settings. Should be PersistenceManager
        config['sync_app'].update(server_paths)
        self.assertTrue(
            type(get_full_sync_manager(config['sync_app']) == FullSyncManager))

        # A conf-specified FullSyncManager is loaded
        config.set("sync_app", "full_sync_manager",
                   'test_full_sync.FakeFullSyncManager')
        self.assertTrue(
            type(get_full_sync_manager(config['sync_app'])) ==
            FakeFullSyncManager)

        # Should fail at load time if the class doesn't inherit from FullSyncManager
        config.set("sync_app", "full_sync_manager",
                   'test_full_sync.BadFullSyncManager')
        with self.assertRaises(TypeError):
            pm = get_full_sync_manager(config['sync_app'])
コード例 #2
0
    def test_get_full_sync_manager(self):
        # Get absolute path to development ini file.
        script_dir = os.path.dirname(os.path.realpath(__file__))
        ini_file_path = os.path.join(script_dir,
                                     "assets",
                                     "test.conf")

        # Create temporary files and dirs the server will use.
        server_paths = helpers.server_utils.create_server_paths()

        config = configparser.ConfigParser()
        config.read(ini_file_path)

        # Use custom files and dirs in settings. Should be PersistenceManager
        config['sync_app'].update(server_paths)
        self.assertTrue(type(get_full_sync_manager(config['sync_app']) == FullSyncManager))

        # A conf-specified FullSyncManager is loaded
        config.set("sync_app", "full_sync_manager", 'test_full_sync.FakeFullSyncManager')
        self.assertTrue(type(get_full_sync_manager(config['sync_app'])) == FakeFullSyncManager)

        # Should fail at load time if the class doesn't inherit from FullSyncManager
        config.set("sync_app", "full_sync_manager", 'test_full_sync.BadFullSyncManager')
        with self.assertRaises(TypeError):
            pm = get_full_sync_manager(config['sync_app'])
コード例 #3
0
    def __init__(self, config, user_manager=None, collection_manager=None):
        from ankisyncd.thread import get_collection_manager

        self.data_root = os.path.abspath(config["data_root"])
        self.base_url = config["base_url"]
        self.base_media_url = config["base_media_url"]
        self.setup_new_collection = None

        self.prehooks = {}
        self.posthooks = {}

        if not user_manager:
            self.user_manager = get_user_manager(config)
        else:
            self.user_manager = user_manager

        if not collection_manager:
            self.collection_manager = get_collection_manager(config)
        else:
            self.collection_manager = collection_manager

        self.session_manager = get_session_manager(config)
        self.full_sync_manager = get_full_sync_manager(config)

        # make sure the base_url has a trailing slash
        if not self.base_url.endswith("/"):
            self.base_url += "/"
        if not self.base_media_url.endswith("/"):
            self.base_media_url += "/"
コード例 #4
0
    def __init__(self, config):
        from ankisyncd.thread import get_collection_manager

        self.data_root = os.path.abspath(config['data_root'])
        self.base_url  = config['base_url']
        self.base_media_url  = config['base_media_url']
        self.setup_new_collection = None

        self.user_manager = get_user_manager(config)
        self.session_manager = get_session_manager(config)
        self.full_sync_manager = get_full_sync_manager(config)
        self.collection_manager = get_collection_manager(config)

        # make sure the base_url has a trailing slash
        if not self.base_url.endswith('/'):
            self.base_url += '/'
        if not self.base_media_url.endswith('/'):
            self.base_media_url += '/'
コード例 #5
0
ファイル: sync_app.py プロジェクト: tsudoko/anki-sync-server
    def __init__(self, config):
        from ankisyncd.thread import get_collection_manager

        self.data_root = os.path.abspath(config['data_root'])
        self.base_url  = config['base_url']
        self.base_media_url  = config['base_media_url']
        self.setup_new_collection = None

        self.prehooks = {}
        self.posthooks = {}

        self.user_manager = get_user_manager(config)
        self.session_manager = get_session_manager(config)
        self.full_sync_manager = get_full_sync_manager(config)
        self.collection_manager = get_collection_manager(config)

        # make sure the base_url has a trailing slash
        if not self.base_url.endswith('/'):
            self.base_url += '/'
        if not self.base_media_url.endswith('/'):
            self.base_media_url += '/'