本文整理汇总了Python中nxdrive.client.RemoteDocumentClient.request_token方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteDocumentClient.request_token方法的具体用法?Python RemoteDocumentClient.request_token怎么用?Python RemoteDocumentClient.request_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nxdrive.client.RemoteDocumentClient
的用法示例。
在下文中一共展示了RemoteDocumentClient.request_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_migration_db_v1
# 需要导入模块: from nxdrive.client import RemoteDocumentClient [as 别名]
# 或者: from nxdrive.client.RemoteDocumentClient import request_token [as 别名]
def test_migration_db_v1(self):
# Initialize old DB
db = open(self._get_db('test_manager_migration.db'), 'rb')
old_db = os.path.join(self.test_folder, 'nxdrive.db')
with open(old_db, 'wb') as f:
f.write(db.read())
db.close()
# Update token with one acquired against the test server
conn = sqlite3.connect(old_db)
c = conn.cursor()
device_id = c.execute("SELECT device_id FROM device_config LIMIT 1").fetchone()[0]
remote_client = RemoteDocumentClient(self.nuxeo_url, self.admin_user, device_id, nxdrive.__version__,
password=self.admin_password)
token = remote_client.request_token()
c.execute("UPDATE server_bindings SET remote_token='%s' WHERE local_folder='%s'" % (
token, '/home/ataillefer/Nuxeo Drive'))
# Update server URL with test server URL
c.execute("UPDATE server_bindings SET server_url='%s' WHERE local_folder='%s'" % (
self.nuxeo_url, '/home/ataillefer/Nuxeo Drive'))
# Update local folder with test temp dir
local_folder = os.path.join(self.test_folder, 'Nuxeo Drive')
c.execute("UPDATE server_bindings SET local_folder='%s' WHERE local_folder='%s'" % (
local_folder, '/home/ataillefer/Nuxeo Drive'))
conn.commit()
conn.close()
# Create Manager with old DB migration
manager = self._create_manager()
dao = manager.get_dao()
# Check Manager config
self.assertEquals(dao.get_config('device_id'), device_id)
self.assertEquals(dao.get_config('proxy_config'), 'Manual')
self.assertEquals(dao.get_config('proxy_type'), 'http')
self.assertEquals(dao.get_config('proxy_server'), 'proxy.server.com')
self.assertEquals(dao.get_config('proxy_port'), '80')
self.assertEquals(dao.get_config('proxy_authenticated'), '1')
self.assertEquals(dao.get_config('proxy_username'), 'Administrator')
self.assertEquals(dao.get_config('auto_update'), '1')
self.assertEquals(dao.get_config('proxy_config'), 'Manual')
# Check engine definition
engines = dao.get_engines()
self.assertEquals(len(engines), 1)
engine = engines[0]
self.assertEquals(engine.engine, 'NXDRIVE')
self.assertEquals(engine.name, manager._get_engine_name(self.nuxeo_url))
self.assertTrue(local_folder in engine.local_folder)
# Check engine config
engine_uid = engine.uid
engine_db = os.path.join(self.test_folder, 'ndrive_%s.db' % engine_uid)
engine_dao = EngineDAO(engine_db)
self.assertEquals(engine_dao.get_config('server_url'), self.nuxeo_url)
self.assertEquals(engine_dao.get_config('remote_user'), 'Administrator')
self.assertEquals(engine_dao.get_config('remote_token'), token)
engine_dao.dispose()
manager.dispose_all()