本文整理汇总了Python中poweradminurt.PoweradminurtPlugin.namecheck方法的典型用法代码示例。如果您正苦于以下问题:Python PoweradminurtPlugin.namecheck方法的具体用法?Python PoweradminurtPlugin.namecheck怎么用?Python PoweradminurtPlugin.namecheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poweradminurt.PoweradminurtPlugin
的用法示例。
在下文中一共展示了PoweradminurtPlugin.namecheck方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mixin_name_checker
# 需要导入模块: from poweradminurt import PoweradminurtPlugin [as 别名]
# 或者: from poweradminurt.PoweradminurtPlugin import namecheck [as 别名]
class mixin_name_checker(object):
def setUp(self):
super(mixin_name_checker, self).setUp()
self.conf = CfgConfigParser()
self.conf.loadFromString("""
[namechecker]
checkdupes: True
checkunknown: True
checkbadnames: True
""")
self.p = PoweradminurtPlugin(self.console, self.conf)
self.init_default_cvar()
self.p.onLoadConfig()
self.p.onStartup()
self.sleep_patcher = patch.object(time, 'sleep')
self.sleep_patcher.start()
self.console.say = Mock()
self.console.write = Mock()
self.p._ignoreTill = 0
def tearDown(self):
super(mixin_name_checker, self).tearDown()
self.sleep_patcher.stop()
def test_checkdupes_no_dup(self):
# GIVEN
p1 = FakeClient(self.console, name="theName", guid="p1guid")
p1.warn = Mock()
p1.connects("1")
p2 = FakeClient(self.console, name="anotherName", guid="p2guid")
p2.warn = Mock()
p2.connects("2")
# WHEN
self.assertFalse(p1.name == p2.name)
self.p.namecheck()
# THEN
self.assertFalse(p1.warn.called)
self.assertFalse(p2.warn.called)
def test_checkdupes_with_dup(self):
# GIVEN
p1 = FakeClient(self.console, name="sameName", guid="p1guid")
p1.warn = Mock()
p1.connects("1")
p2 = FakeClient(self.console, name="sameName", guid="p2guid")
p2.warn = Mock()
p2.connects("2")
# WHEN
self.assertTrue(p1.name == p2.name)
self.p.namecheck()
# THEN
p1.warn.assert_has_calls([call(ANY, ANY, 'badname', None, '')])
p2.warn.assert_has_calls([call(ANY, ANY, 'badname', None, '')])
def test_checkdupes_with_player_reconnecting(self):
# GIVEN
p1 = FakeClient(self.console, name="sameName", guid="p1guid")
p1.warn = Mock()
p1.connects("1")
# WHEN
p1.disconnects()
p1.connects("2")
self.p.namecheck()
# THEN
self.assertFalse(p1.warn.called)
def test_checkunknown(self):
# GIVEN
p1 = FakeClient(self.console, name="New UrT Player", guid="p1guid")
p1.warn = Mock()
p1.connects("1")
# WHEN
self.p.namecheck()
# THEN
p1.warn.assert_has_calls([call(ANY, ANY, 'badname', None, '')])
def test_checkbadnames(self):
# GIVEN
p1 = FakeClient(self.console, name="all", guid="p1guid")
p1.warn = Mock()
p1.connects("1")
# WHEN
self.p.namecheck()
# THEN
p1.warn.assert_has_calls([call(ANY, ANY, 'badname', None, '')])