本文整理汇总了Python中inbox.mailsync.service.SyncService._get_local_accounts方法的典型用法代码示例。如果您正苦于以下问题:Python SyncService._get_local_accounts方法的具体用法?Python SyncService._get_local_accounts怎么用?Python SyncService._get_local_accounts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inbox.mailsync.service.SyncService
的用法示例。
在下文中一共展示了SyncService._get_local_accounts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sync_start
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import _get_local_accounts [as 别名]
def test_sync_start(db, default_account, config):
# Make sure having fqdn set locally gets assigned to us
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == [1]
# Not from other cpus
ss = SyncService(cpu_id=1, total_cpus=1)
assert ss._get_local_accounts() == []
# Different host
default_account.sync_host = "some-random-host"
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []
# Explicit
default_account.sync_host = platform.node()
db.session.commit()
assert ss._get_local_accounts() == [1]
default_account.sync_host = None
db.session.commit()
# No host, work stealing enabled
config['SYNC_STEAL_ACCOUNTS'] = True
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == [1]
# No host, no work stealing disabled
config['SYNC_STEAL_ACCOUNTS'] = False
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []
default_account.sync_state = 'stopped'
# Stopped
default_account.sync_host = None
db.session.commit()
# Don't steal stopped accounts
config['SYNC_STEAL_ACCOUNTS'] = True
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []
# Don't explicitly start stopped accounts
default_account.sync_host = platform.node()
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []
# Invalid Credentials
default_account.sync_state = 'invalid'
db.session.commit()
# Don't steal invalid accounts
config['SYNC_STEAL_ACCOUNTS'] = True
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []
# Don't explicitly start invalid accounts
default_account.sync_host = platform.node()
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss._get_local_accounts() == []