当前位置: 首页>>代码示例>>Python>>正文


Python SyncService._get_local_accounts方法代码示例

本文整理汇总了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() == []
开发者ID:Dracophoenix1,项目名称:inbox,代码行数:67,代码来源:test_sync_start_logic.py


注:本文中的inbox.mailsync.service.SyncService._get_local_accounts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。