本文整理汇总了Python中gutter.client.models.Switch.state方法的典型用法代码示例。如果您正苦于以下问题:Python Switch.state方法的具体用法?Python Switch.state怎么用?Python Switch.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gutter.client.models.Switch
的用法示例。
在下文中一共展示了Switch.state方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_register_signals_and_get_notified
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def test_can_register_signals_and_get_notified(self):
signals.switch_registered.connect(self.callback.switch_added)
signals.switch_unregistered.connect(self.callback.switch_removed)
signals.switch_updated.connect(self.callback.switch_updated)
eq_(self.callback.register_calls, [])
eq_(self.callback.unregister_calls, [])
eq_(self.callback.update_calls, [])
switch = Switch("foo")
self.manager.register(switch)
eq_(self.callback.register_calls, [switch])
self.manager.unregister(switch.name)
eq_(self.callback.unregister_calls, [switch])
self.manager.register(switch)
eq_(self.callback.register_calls, [switch, switch])
switch.state = Switch.states.GLOBAL
self.manager.update(switch)
change = self.callback.update_calls[0]
eq_(change[0], switch)
changes = change[1]
eq_(changes["state"], dict(current=Switch.states.GLOBAL, previous=Switch.states.DISABLED))
示例2: test_switch_state_can_be_changed
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def test_switch_state_can_be_changed(self):
switch = Switch("foo")
old_state = switch.state
switch.state = Switch.states.GLOBAL
eq_(switch.state, Switch.states.GLOBAL)
ok_(old_state is not switch.state)
示例3: test_retrieved_switches_can_be_updated
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def test_retrieved_switches_can_be_updated(self):
switch = Switch("foo")
self.manager.register(switch)
self.assertEquals(self.manager.switch("foo").name, "foo")
switch.state = Switch.states.GLOBAL
switch.save()
self.assertEquals(self.manager.switch("foo").state, Switch.states.GLOBAL)
示例4: add_switch
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def add_switch(self, name, condition=None, *conditions, **kwargs):
switch = Switch(name, compounded=kwargs.get("compounded", False))
switch.state = kwargs.get("state", Switch.states.SELECTIVE)
conditions = list(conditions)
if condition:
conditions.append(condition)
[switch.conditions.append(c) for c in conditions]
kwargs.get("manager", self.manager).register(switch)
return switch
示例5: test_retrieved_switches_can_be_updated
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def test_retrieved_switches_can_be_updated(self):
switch = Switch('foo')
self.manager.register(switch)
switch.name = 'steve'
switch.save()
self.assertRaises(ValueError, self.manager.switch, 'foo')
self.assertEquals(self.manager.switch('steve').name, 'steve')
switch.name = 'bob'
switch.state = Switch.states.GLOBAL
switch.save()
self.assertEquals(self.manager.switch('bob').name, 'bob')
self.assertEquals(
self.manager.switch('bob').state,
Switch.states.GLOBAL
)
self.assertRaises(ValueError, self.manager.switch, 'steve')
示例6: test_can_register_signals_and_get_notified
# 需要导入模块: from gutter.client.models import Switch [as 别名]
# 或者: from gutter.client.models.Switch import state [as 别名]
def test_can_register_signals_and_get_notified(self):
signals.switch_registered.connect(self.callback.switch_added)
signals.switch_unregistered.connect(self.callback.switch_removed)
signals.switch_updated.connect(self.callback.switch_updated)
eq_(self.callback.register_calls, [])
eq_(self.callback.unregister_calls, [])
eq_(self.callback.update_calls, [])
switch = Switch('foo')
self.manager.register(switch)
eq_(self.callback.register_calls, [switch])
self.manager.unregister(switch.name)
eq_(self.callback.unregister_calls, [switch])
self.manager.register(switch)
eq_(self.callback.register_calls, [switch, switch])
switch.name = 'a new name'
switch.state = Switch.states.GLOBAL
self.manager.update(switch)
change = self.callback.update_calls[0]
eq_(change[0], switch)
changes = change[1]
eq_(changes['name'], dict(current='a new name', previous='foo'))
eq_(changes['state'], dict(current=Switch.states.GLOBAL, previous=Switch.states.DISABLED))
switch.name = 'from save() call'
switch.save()
change = self.callback.update_calls[1]
eq_(change[0], switch)
changes = change[1]
eq_(changes['name'], dict(current='from save() call', previous='a new name'))