當前位置: 首頁>>代碼示例>>Python>>正文


Python PoweradminurtPlugin.namecheck方法代碼示例

本文整理匯總了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, '')])
開發者ID:danielepantaleone,項目名稱:b3-plugin-poweradminurt,代碼行數:96,代碼來源:test_name_checker.py


注:本文中的poweradminurt.PoweradminurtPlugin.namecheck方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。