• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fake.FakeClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中b3.fake.FakeClient的典型用法代码示例。如果您正苦于以下问题:Python FakeClient类的具体用法?Python FakeClient怎么用?Python FakeClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FakeClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        # create a B3 FakeConsole
        self.parser_conf = XmlConfigParser()
        self.parser_conf.loadFromString(r"""<configuration/>""")
        self.console = FakeConsole(self.parser_conf)
        # create our plugin instance
        self.plugin_conf = CfgConfigParser()
        self.p = Killannouncerbf3Plugin(self.console, self.plugin_conf)
        # initialise the plugin
        self.plugin_conf.loadFromString(r'''
[settings]
announce first kill: yes
[first kill alert]
us1: %(murderer)s takes first blood against %(victim)s! The battle has just began!!!
de1: %(murderer)s hat das erste Blut von %(victim)s genommen! Die Schlacht hat begonnen!!!
[kill streak alerts]
us1 #5: Killing Spree! %(murderer)s is dominating on a %(kill_streak_value)s kill streak!
us2 #10: Killing Spree! %(murderer)s is dominating on a %(kill_streak_value)s kill streak!
[end kill streak alerts]
us1: %(murderer)s has ended %(murderer)s kill streak at %(kill_streak_value)s kills!

        ''')
        # Plugin ipinfodb is required. We trick and set county property later.
        self.p.console._plugins['ipinfodb'] = ''

        self.p.onLoadConfig()
        self.p.onStartup()
        # prepare a few players
        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, country='de',team=TEAM_RED)
        self.simon = FakeClient(self.console, name="Simon", exactName="Simon", guid="qsdfdsqfdsqf", groupBits=0, country='us',team=TEAM_BLUE)
        self.admin = FakeClient(self.console, name="Level-40-Admin", exactName="Level-40-Admin", guid="875sasda", groupBits=16, country='ch',)
        self.superadmin = FakeClient(self.console, name="God", exactName="God", guid="f4qfer654r", groupBits=128, country='fr',)

        self.joe.connects(cid='1')
        self.simon.connects(cid='2')
开发者ID:ozon,项目名称:b3-plugin-killannouncerbf3,代码行数:35,代码来源:test_killannouncer.py


示例2: setUp

    def setUp(self):
        self.parser_conf = MainConfig(CfgConfigParser(allow_no_value=True))
        self.parser_conf.loadFromString(dedent(r""""""))
        self.console = FakeConsole(self.parser_conf)
        self.console.gameName = 'f00'
        self.console.startup()

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin.onLoadConfig()
            self.adminPlugin.onStartup()

        self.evt_queue = []

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        with logging_disabled():
            from b3.fake import FakeClient

        # prepare a few players
        self.mike = FakeClient(self.console, name="Mike", exactName="Mike", guid="MIKEGUID", groupBits=16, ip='1.1.1.1')
        self.paul = FakeClient(self.console, name="Paul", exactName="Paul", guid="PAULGUID", groupBits=1, ip='2.2.2.2')
        self.john = FakeClient(self.console, name="John", exactName="John", guid="JOHNGUID", groupBits=0, ip='3.3.3.3')
        self.mary = FakeClient(self.console, name="Mary", exactName="Mary", guid="MARYGUID", groupBits=0, ip='4.4.4.4')

        self.conf = CfgConfigParser()
        self.p = IpbanPlugin(self.console, self.conf)

        # return some mock data
        when(self.p).getBanIps().thenReturn(['2.2.2.2', '6.6.6.6', '7.7.7.7'])
        when(self.p).getTempBanIps().thenReturn(['3.3.3.3', '8.8.8.8', '9.9.9.9'])
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:32,代码来源:__init__.py


示例3: setUp

    def setUp(self):
        B3TestCase.setUp(self)

        with logging_disabled():
            admin_conf = CfgConfigParser()
            admin_plugin = AdminPlugin(self.console, admin_conf)
            admin_plugin.onLoadConfig()
            admin_plugin.onStartup()
            when(self.console).getPlugin('admin').thenReturn(admin_plugin)

        conf = CfgConfigParser()
        conf.loadFromString(dedent(r"""
            [commands]
            mapstats-stats: 0
            testscore-ts: 0
            topstats-top: 0
            topxp: 0

            [settings]
            startPoints: 100
            resetscore: no
            resetxp: no
            show_awards: no
            show_awards_xp: no
        """))
        self.p = StatsPlugin(self.console, conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED)
        self.joe.connects(1)
        self.mike.connects(2)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:33,代码来源:__init__.py


示例4: Cmd_regulars

class Cmd_regulars(Admin_functional_test):
    def setUp(self):
        Admin_functional_test.setUp(self)
        self.init()
        self.joe.message = Mock(wraps=lambda x: sys.stdout.write("\t\t" + x + "\n"))
        self.joe.connects(0)

    def test_no_regular(self):
        # only superadmin joe is connected
        self.joe.says("!regulars")
        self.joe.message.assert_called_with("^7There are no regular players online")

    def test_one_regular(self):
        # GIVEN
        self.mike.connects(1)
        self.joe.says("!makereg mike")
        # WHEN
        self.joe.says("!regs")
        # THEN
        self.joe.message.assert_called_with("^7Regular players online: Mike^7")

    def test_two_regulars(self):
        # GIVEN
        self.mike.connects(1)
        self.joe.says("!makereg mike")
        self.jack = FakeClient(self.console, name="Jack", guid="jackguid", groupBits=1)
        self.jack.connects(2)
        self.joe.says("!makereg jack")
        # WHEN
        self.joe.says("!regs")
        # THEN
        self.joe.message.assert_called_with("^7Regular players online: Mike^7, Jack^7")
开发者ID:derfull,项目名称:big-brother-bot,代码行数:32,代码来源:test_admin_functional.py


示例5: setUp

    def setUp(self):
        CalladminTestCase.setUp(self)
        self.conf = CfgConfigParser()
        self.conf.loadFromString(dedent(r"""
            [teamspeak]
            ip: 127.0.0.1
            port: 10011
            serverid: 1
            username: fakeusername
            password: fakepassword
            msg_groupid: -1

            [settings]
            treshold: 3600
            useirc: no

            [commands]
            calladmin: user
        """))

        self.p = CalladminPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        with logging_disabled():
            from b3.fake import FakeClient

        self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", groupBits=1)
        self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", groupBits=16)
开发者ID:danielepantaleone,项目名称:b3-plugin-calladmin,代码行数:29,代码来源:test_events.py


示例6: setUp

 def setUp(self):
     XlrstatsTestCase.setUp(self)
     self.init()
     self.p1 = FakeClient(console=self.console, name="P1", guid="P1_GUID")
     self.p1.connects("1")
     self.p2 = FakeClient(console=self.console, name="P2", guid="P2_GUID")
     self.p2.connects("2")
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:7,代码来源:test_xlrstats.py


示例7: test_existing_player

 def test_existing_player(self):
     joe = FakeClient(self.console, name="Joe", guid="01230123012301230123", groupBits=1)
     joe.connects('1')
     self.assertEqual(joe, self.console.clients['1'])
     when(self.console).write("startserverdemo 1").thenReturn("startserverdemo: recording Joe to serverdemos/2012_04_22_20-16-38_Joe_642817.dm_68")
     self.moderator.says("!startserverdemo joe")
     self.assertListEqual(['startserverdemo: recording Joe to serverdemos/2012_04_22_20-16-38_Joe_642817.dm_68'], self.moderator.message_history)
开发者ID:thomasleveil,项目名称:b3-plugin-urt-serverside-demo,代码行数:7,代码来源:test_startserverdemo.py


示例8: setUp

    def setUp(self):
        # create a FakeConsole parser
        parser_ini_conf = CfgConfigParser()
        parser_ini_conf.loadFromString(r'''''')
        self.parser_main_conf = MainConfig(parser_ini_conf)

        with logging_disabled():
            from b3.fake import FakeConsole
            self.console = FakeConsole(self.parser_main_conf)

        with logging_disabled():
            self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
            self.adminPlugin._commands = {}
            self.adminPlugin.onStartup()

        # make sure the admin plugin obtained by other plugins is our admin plugin
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        # simulate geolocation plugin registering events
        self.console.createEvent('EVT_CLIENT_GEOLOCATION_SUCCESS', 'Event client geolocation success')

        self.console.screen = Mock()
        self.console.time = time.time
        self.console.upTime = Mock(return_value=1000)
        self.console.cron.stop()


        self.conf = CfgConfigParser()
        self.conf.loadFromString(dedent(r"""
            [settings]
            announce: yes

            [messages]
            client_connect: ^7$name ^3from ^7$city ^3(^7$country^3) connected
            cmd_locate: ^7$name ^3is connected from ^7$city ^3(^7$country^3)
            cmd_locate_failed: ^7Could not locate ^1$name
            cmd_distance: ^7$name ^3is ^7$distance ^3km away from you
            cmd_distance_self: ^7Sorry, I'm not that smart...meh!
            cmd_distance_failed: ^7Could not compute distance with ^1$name
            cmd_isp: ^7$name ^3is using ^7$isp ^3as isp
            cmd_isp_failed: ^7Could not determine ^1$name ^7isp

            [commands]
            locate: user
            distance: user
            isp: mod
        """))

        self.p = LocationPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        with logging_disabled():
            from b3.fake import FakeClient

        self.mike = FakeClient(console=self.console, name="Mike", guid="MIKEGUID", groupBits=1)
        self.bill = FakeClient(console=self.console, name="Bill", guid="BILLGUID", groupBits=16)
        self.mike.location = LOCATION_MIKE
        self.bill.location = LOCATION_BILL
开发者ID:danielepantaleone,项目名称:b3-plugin-location,代码行数:59,代码来源:__init__.py


示例9: test_map_with_correct_parameters

 def test_map_with_correct_parameters(self):
     # GIVEN
     superadmin = FakeClient(self.parser, name="superadmin", guid="guid_superadmin", groupBits=128, team=TEAM_UNKNOWN)
     superadmin.connects("1")
     # WHEN
     superadmin.says("!map market push")
     # THEN
     self.parser.output.write.assert_has_calls([call('changelevel market push')])
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:8,代码来源:test_insurgency.py


示例10: test_SUICIDE

 def test_SUICIDE(self):  # 16
     # GIVEN
     poorguy = FakeClient(self.parser, name="attacker_name", guid='76561198070138838')
     poorguy.connects("1")
     # WHEN
     self.parser.handlePacket(Packet.decode('\x00\x10\x00\x00\x00\x08\x01\x10\x00\x01\x06\x8c\x87\xd6'))
     # THEN
     self.assert_has_event("EVT_CLIENT_SUICIDE", client=poorguy, target=poorguy, data=(100, None, None))
开发者ID:BigBrotherBot,项目名称:big-brother-bot,代码行数:8,代码来源:test_chiv.py


示例11: setUp

 def setUp(self):
     Iourt41TestCase.setUp(self)
     self.console.startup()
     self.joe = FakeClient(self.console, name="Joe", guid="000000000000000")
     self.joe.connects('0')
     self.bob = FakeClient(self.console, name="Bob", guid="111111111111111")
     self.bob.connects('1')
     self.world = self.console.clients['-1']
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:8,代码来源:test_iourt41.py


示例12: test_checkbadnames

 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,代码行数:9,代码来源:test_name_checker.py


示例13: test_killed_but_really_is_suicide

 def test_killed_but_really_is_suicide(self):
     # GIVEN
     bot22 = FakeClient(self.parser, name="Pheonix", guid="BOT_22")
     bot22.connects("22")
     # WHEN
     self.clear_events()
     self.parser.parseLine('''L 08/26/2012 - 03:46:44: "Pheonix<22><BOT><TERRORIST>" killed "Pheonix<22><BOT><TERRORIST>" with "glock"''')
     # THEN
     self.assert_has_event("EVT_CLIENT_SUICIDE", client=bot22, target=bot22, data=(100, 'glock', 'body', None))
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:9,代码来源:test_csgo.py


示例14: test_player_entered

 def test_player_entered(self):
     # GIVEN
     player = FakeClient(self.parser, name="courgette", guid="STEAM_1:0:1111111")
     player.connects("2")
     # WHEN
     self.clear_events()
     self.parser.parseLine('''L 08/26/2012 - 05:38:36: "courgette<2><STEAM_1:0:1111111><>" entered the game''')
     # THEN
     self.assert_has_event("EVT_CLIENT_JOIN", client=player)
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:9,代码来源:test_csgo.py


示例15: test_low_level

 def test_low_level(self):
     # GIVEN
     joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=8)
     # WHEN
     joe.clearMessageHistory()
     joe.connects("0")
     # THEN
     self.assertEqual([], joe.message_history)
     self.assertEqual(8, joe.groupBits)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:9,代码来源:test_events.py


示例16: test_Verified_guid__with_connected_player

 def test_Verified_guid__with_connected_player(self):
     # GIVEN
     bravo17 = FakeClient(self.parser, name="Bravo17")
     bravo17.connects("0")
     self.clear_events()
     # WHEN
     self.parser.routeBattleyeEvent("""Verified GUID (80a5885ebe2420bab5e158a310fcbc7d) of player #0 Bravo17""")
     # THEN
     self.assert_has_event("EVT_CLIENT_AUTH", data=bravo17, client=bravo17)
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:9,代码来源:test_arma2.py


示例17: test_clantag

 def test_clantag(self):
     # GIVEN
     player = FakeClient(self.parser, name="courgette", guid="STEAM_1:0:1111111", team=TEAM_BLUE)
     player.connects("2")
     # WHEN
     self.assertFalse(hasattr(player, "clantag"))
     self.parser.parseLine('''L 08/26/2012 - 05:43:31: "courgette<2><STEAM_1:0:1111111><CT>" triggered "clantag" (value "f00")''')
     # THEN
     self.assertEqual("f00", player.clantag)
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:9,代码来源:test_csgo.py


示例18: setUp

    def setUp(self):
        ProxyfilterTestCase.setUp(self)

        with logging_disabled():
            from b3.fake import FakeClient

        # create some fake clients
        self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", ip="127.0.0.1", groupBits=128)
        self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", ip="127.0.0.2", groupBits=1)
开发者ID:danielepantaleone,项目名称:b3-plugin-proxyfilter,代码行数:9,代码来源:test_commands.py


示例19: test_client_teamsay

 def test_client_teamsay(self):
     # GIVEN
     player = FakeClient(self.parser, name="courgette", guid="STEAM_1:0:1111111", team=TEAM_BLUE)
     player.connects("2")
     # WHEN
     self.clear_events()
     self.parser.parseLine('''L 08/26/2012 - 05:04:44: "courgette<2><STEAM_1:0:1111111><CT>" say_team "team say"''')
     # THEN
     self.assert_has_event("EVT_CLIENT_TEAM_SAY", "team say", player)
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:9,代码来源:test_csgo.py


示例20: test_client_say__no_team

 def test_client_say__no_team(self):
     # GIVEN
     player = FakeClient(self.parser, name="Spoon", guid="STEAM_1:0:10000000", team=TEAM_UNKNOWN)
     player.connects("2")
     # WHEN
     self.clear_events()
     self.parser.parseLine('''L 09/16/2012 - 04:55:17: "Spoon<2><STEAM_1:0:10000000><>" say "!h"''')
     # THEN
     self.assert_has_event("EVT_CLIENT_SAY", "!h", player)
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:9,代码来源:test_csgo.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python functions.splitDSN函数代码示例发布时间:2022-05-24
下一篇:
Python config.XmlConfigParser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap