Ejemplo n.º 1
0
    def setUpClass(cls):
        global p, joe, conf

        ## create an instance of the plugin to test
        p = TeamspeakbfPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()
        joe.connects('Joe')

        timeout = time.time() + 10
        while not p.tsconnection and time.time() < timeout:
            time.sleep(.1)
        if not p.tsconnection:
            raise AssertionError("Could not connect to TeamSpeak server")

        if not p.tsGetClient(joe):
            raise unittest.SkipTest(
                "please connect to the test Teamspeak server first and make sure your ip is %s as set in config.ini"
                % config.get("me", "ip"))

        channellist = p.tsSendCommand('channellist')
        cls.tsDefaultChannel = p.tsGetChannelIdByName(u'Default Channel',
                                                      channellist)
        if not cls.tsDefaultChannel:
            raise unittest.SkipTest("Could not get default teamspeak channel")
Ejemplo n.º 2
0
 def test_DefaultTarget_off(self):
     conf = XmlConfigParser()
     conf.setXml("""
     <configuration plugin="teamspeakbf">
     	<settings name="teamspeakServer">
             <set name="host">foo_host</set>
             <set name="queryport">foo_queryport</set>
             <set name="id">1</set>
             <set name="login">foo_login</set>
             <set name="password">foo_password</set>
         </settings>
         <settings name="teamspeakChannels">
             <set name="DefaultTarget">off</set>
         </settings>
     </configuration>
     """)
     p = TeamspeakbfPlugin(fakeConsole, conf)
     p.readConfig()
     self.assertEqual('off', p.autoswitchDefaultTarget)
Ejemplo n.º 3
0
 def test_default_values(self):
     conf = XmlConfigParser()
     conf.setXml("""
     <configuration plugin="teamspeakbf">
     	<settings name="teamspeakServer">
             <set name="host">foo_host</set>
             <set name="queryport">foo_queryport</set>
             <set name="id">1</set>
             <set name="login">foo_login</set>
             <set name="password">foo_password</set>
         </settings>
     </configuration>
     """)
     p = TeamspeakbfPlugin(fakeConsole, conf)
     p.readConfig()
     self.assertEqual(TeamspeakbfPlugin.TS3ChannelB3, p.TS3ChannelB3)
     self.assertEqual(TeamspeakbfPlugin.TS3ChannelTeam1, p.TS3ChannelTeam1)
     self.assertEqual(TeamspeakbfPlugin.TS3ChannelTeam2, p.TS3ChannelTeam2)
     self.assertEqual(TeamspeakbfPlugin.autoswitchDefaultTarget, p.autoswitchDefaultTarget)
Ejemplo n.º 4
0
    def test_with_player(self):
        # count minimum channels
        initial_num_channels = len(Test_shutdown.ts3.get_channellist())

        ## create an instance of the plugin to test
        p = TeamspeakbfPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()

        superadmin.connects('superadmin')

        if not p.tsGetClient(superadmin):
            raise unittest.SkipTest(
                "please connect to the test Teamspeak server first and make sure your ip is %s as set in config.ini"
                % config.get("me", "ip"))

        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterinit_num_channels = len(clist)
        self.assertLess(initial_num_channels, afterinit_num_channels)

        superadmin.says('!ts join')
        time.sleep(.5)

        superadmin.says('!die')
        timeout = time.time() + 20
        while p.connected and time.time() < timeout:
            time.sleep(.5)
        if p.connected:
            self.fail("Could not disconnect from TeamSpeak server")

        time.sleep(.5)
        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterdeath_num_channels = len(clist)
        self.assertGreaterEqual(initial_num_channels, afterdeath_num_channels)
Ejemplo n.º 5
0
		<set name="team2">Team 2</set>
	</settings>
	<settings name="commands">
		<set name="tsreconnect">100</set>
		<set name="tsdisconnect">100</set>
        <set name="teamspeak-ts">0</set>
        <set name="tsauto-tsa">0</set>
	</settings>
</configuration>
""".format(ts_host=config.get("teamspeak_server", "host"),
           ts_port=config.get("teamspeak_server", "port"),
           ts_id=config.get("teamspeak_server", "id"),
           ts_login=config.get("teamspeak_server", "login"),
           ts_password=config.get("teamspeak_server", "password")))

p = TeamspeakbfPlugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()


def instruct(instructions):
    print "\n\n> %s" % instructions
    raw_input("type ENTER when ready")


me = FakeClient(fakeConsole,
                name="me",
                guid="zaerazerazerzaer",
                groupBits=128,
                team=TEAM_UNKNOWN,
                ip=config.get("me", "ip"))