本文整理汇总了Python中inbox.mailsync.service.SyncService.accounts_to_start方法的典型用法代码示例。如果您正苦于以下问题:Python SyncService.accounts_to_start方法的具体用法?Python SyncService.accounts_to_start怎么用?Python SyncService.accounts_to_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inbox.mailsync.service.SyncService
的用法示例。
在下文中一共展示了SyncService.accounts_to_start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_concurrent_syncs
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_concurrent_syncs(db, default_account, config):
ss1 = SyncService(cpu_id=1, total_cpus=2)
ss2 = SyncService(cpu_id=1, total_cpus=2)
ss2.host = 'other-host'
# Check that only one SyncService instance claims the account.
assert ss1.accounts_to_start() == [1]
assert ss2.accounts_to_start() == []
示例2: test_dont_start_disabled_accounts
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_dont_start_disabled_accounts(db, config, default_account):
purge_other_accounts(default_account)
config['SYNC_STEAL_ACCOUNTS'] = True
default_account.sync_host = None
default_account.disable_sync(reason='testing')
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss.accounts_to_start() == []
assert default_account.sync_host is None
assert default_account.sync_should_run is False
default_account.sync_host = platform.node()
default_account.disable_sync('testing')
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss.accounts_to_start() == []
assert default_account.sync_should_run is False
# Invalid Credentials
default_account.mark_invalid()
default_account.sync_host = None
db.session.commit()
# Don't steal invalid accounts
ss = SyncService(cpu_id=0, total_cpus=1)
assert ss.accounts_to_start() == []
# 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.accounts_to_start() == []
示例3: test_concurrent_syncs
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_concurrent_syncs(db, default_account, config):
purge_other_accounts(default_account)
ss1 = SyncService(cpu_id=default_account.id % 2, total_cpus=2)
ss2 = SyncService(cpu_id=default_account.id % 2, total_cpus=2)
ss2.host = "other-host"
# Check that only one SyncService instance claims the account.
assert ss1.accounts_to_start() == [default_account.id]
assert ss2.accounts_to_start() == []
示例4: test_start_new_accounts_when_stealing_enabled
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_start_new_accounts_when_stealing_enabled(db, default_account):
default_account.sync_host = None
db.session.commit()
ss = SyncService(cpu_id=1, total_cpus=2)
assert ss.accounts_to_start() == [1]
db.session.expire_all()
assert default_account.sync_host == platform.node()
示例5: test_dont_start_new_accounts_when_stealing_disabled
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_dont_start_new_accounts_when_stealing_disabled(db, config, default_account):
purge_other_accounts(default_account)
default_account.sync_host = None
db.session.commit()
config["SYNC_STEAL_ACCOUNTS"] = False
ss = SyncService(cpu_id=default_account.id % 2, total_cpus=2)
assert ss.accounts_to_start() == []
assert default_account.sync_host is None
示例6: test_sync_transitions
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_sync_transitions(db, default_account, config):
purge_other_accounts(default_account)
ss = SyncService(cpu_id=default_account.id % 2, total_cpus=2)
default_account.enable_sync()
db.session.commit()
assert ss.accounts_to_start() == [default_account.id]
default_account.disable_sync("manual")
db.session.commit()
assert ss.accounts_to_start() == []
assert default_account.sync_should_run is False
assert default_account._sync_status["sync_disabled_reason"] == "manual"
default_account.mark_invalid()
db.session.commit()
assert ss.accounts_to_start() == []
assert default_account.sync_state == "invalid"
assert default_account._sync_status["sync_disabled_reason"] == "invalid credentials"
assert default_account.sync_should_run is False
示例7: test_sync_transitions
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_sync_transitions(db, default_account, config):
ss = SyncService(cpu_id=1, total_cpus=2)
default_account.enable_sync()
db.session.commit()
assert ss.accounts_to_start() == [1]
default_account.disable_sync('manual')
db.session.commit()
assert ss.accounts_to_start() == []
assert default_account.sync_should_run is False
assert default_account._sync_status['sync_disabled_reason'] == 'manual'
default_account.mark_invalid()
db.session.commit()
assert ss.accounts_to_start() == []
assert default_account.sync_state == 'invalid'
assert default_account._sync_status['sync_disabled_reason'] == \
'invalid credentials'
assert default_account.sync_should_run is False
示例8: test_stealing_limited_by_host
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_stealing_limited_by_host(db, config):
host = platform.node()
config['DATABASE_HOSTS'][0]['SHARDS'][0]['SYNC_HOSTS'] = [host]
config['DATABASE_HOSTS'][0]['SHARDS'][1]['SYNC_HOSTS'] = ['otherhost']
purge_other_accounts()
ss = SyncService(cpu_id=0, total_cpus=1)
for key in (0, 1):
with session_scope_by_shard_id(key) as db_session:
acc = Account()
acc.namespace = Namespace()
db_session.add(acc)
db_session.commit()
ss.accounts_to_start()
with session_scope_by_shard_id(0) as db_session:
acc = db_session.query(Account).first()
assert acc.sync_host == host
with session_scope_by_shard_id(1) as db_session:
acc = db_session.query(Account).first()
assert acc.sync_host is None
示例9: test_accounts_started_on_all_shards
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_accounts_started_on_all_shards(db, default_account, config):
config['SYNC_STEAL_ACCOUNTS'] = True
purge_other_accounts(default_account)
default_account.sync_host = None
db.session.commit()
ss = SyncService(cpu_id=0, total_cpus=1)
ss.host = 'localhost'
account_ids = {default_account.id}
for key in (0, 1):
with session_scope_by_shard_id(key) as db_session:
acc = Account()
acc.namespace = Namespace()
db_session.add(acc)
db_session.commit()
account_ids.add(acc.id)
assert len(account_ids) == 3
assert set(ss.accounts_to_start()) == account_ids
for id_ in account_ids:
with session_scope(id_) as db_session:
acc = db_session.query(Account).get(id_)
assert acc.sync_host == 'localhost'
示例10: test_dont_start_accounts_on_other_host
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_dont_start_accounts_on_other_host(db, default_account):
purge_other_accounts(default_account)
default_account.sync_host = 'other-host'
db.session.commit()
ss = SyncService(cpu_id=1, total_cpus=2)
assert ss.accounts_to_start() == []
示例11: test_dont_start_accounts_for_other_cpus
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_dont_start_accounts_for_other_cpus(db, default_account):
purge_other_accounts(default_account)
default_account.sync_host = platform.node()
ss = SyncService(cpu_id=default_account.id + 1, total_cpus=2**22)
assert ss.accounts_to_start() == []
示例12: test_start_already_assigned_accounts
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_start_already_assigned_accounts(db, default_account):
purge_other_accounts(default_account)
default_account.sync_host = platform.node()
ss = SyncService(cpu_id=default_account.id % 2, total_cpus=2)
assert ss.accounts_to_start() == [default_account.id]
示例13: test_start_already_assigned_accounts
# 需要导入模块: from inbox.mailsync.service import SyncService [as 别名]
# 或者: from inbox.mailsync.service.SyncService import accounts_to_start [as 别名]
def test_start_already_assigned_accounts(db, default_account):
default_account.sync_host = platform.node()
ss = SyncService(cpu_id=1, total_cpus=2)
assert ss.accounts_to_start() == [1]