コード例 #1
0
                        _max = value

                message_add_rule = messages.KZorpAddRuleMessage(dispatcher['name'],
                                                       rule['rule_id'],
                                                       rule['service'],
                                                       rule['entry_nums']
                                                       )
                self.send_message(message_add_rule)

                for i in range(_max):
                    data = {}
                    for dim_type in messages.N_DIMENSION_ATTRS:
                        if dim_type in rule['entry_nums'] and rule['entry_nums'][dim_type] > i:
                            if dim_type in [messages.KZNL_ATTR_N_DIMENSION_SRC_IP, messages.KZNL_ATTR_N_DIMENSION_DST_IP]:
                                subnet = rule['entry_values'][dim_type][i]
                                data[dim_type] = (testutil.addr_packed(subnet), testutil.netmask_packed(subnet))
                            elif dim_type in [messages.KZNL_ATTR_N_DIMENSION_SRC_IP6, messages.KZNL_ATTR_N_DIMENSION_DST_IP6]:
                                subnet = rule['entry_values'][dim_type][i]
                                data[dim_type] = (testutil.addr_packed6(subnet), testutil.netmask_packed6(subnet))
                            else:
                                data[dim_type] = rule['entry_values'][dim_type][i]
                    #print "rule=%s\ndispatcher=%s\ndata=%s\n"%(rule,dispatcher['name'],data)
                    message_add_rule_entry = messages.KZorpAddRuleEntryMessage(dispatcher['name'], rule['rule_id'], data)

                    self.send_message(message_add_rule_entry)

        self.end_transaction()

if __name__ == "__main__":
    testutil.main()
コード例 #2
0
        for bind_addr in self._bind_addrs:
            bind_addr["port"] -= 1000

        self._dumped_binds = []
        self.get_bind()

        self.assertEqual(len(self._dumped_binds), len(self._bind_addrs) * 2)

        # close new handle and check if only the binds of the original handle remain
        self.close_handle()
        self.handle = orig_handle

        self._dumped_binds = []
        self.get_bind()

        self.assertEqual(len(self._dumped_binds), len(self._bind_addrs))
        for i in range(bind_addr_num):
            msg_add_bind = kznl.KZorpAddBindMessage(**self._bind_addrs[i])
            self.assertEqual(vars(msg_add_bind), vars(self._dumped_binds[i]))

        self.reopen_handle()

        self._dumped_binds = []
        self.get_bind()
        self.assertEqual(len(self._dumped_binds), 0)

if __name__ == "__main__":
    testutil.main()

コード例 #3
0
import wx
from testutil import main


def test_notaskbar():
    f = lambda: wx.Frame(
        None, -1, style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_NO_TASKBAR)

    frames = [f() for x in xrange(10)]
    for frame in frames:
        frame.Destroy()


if __name__ == '__main__':
    main(test_notaskbar)
コード例 #4
0
ファイル: test_evthandler.py プロジェクト: ifwe/wxpy
from testutil import check_collected, main
import wx

def test_selfcycle():
    return

    f = wx.Frame(None)

    class MyEventHandler(wx.EvtHandler):
        def __init__(self):
            wx.EvtHandler.__init__(self)
            self.Bind(wx.EVT_MENU, self.on_menu)

        def on_menu(self, e):
            print 'Menu Event', e

    @check_collected
    def cycle():
        return MyEventHandler()

    f.Destroy()

    print 'no cycle!'

if __name__ == '__main__':
    main(test_selfcycle)
コード例 #5
0
ファイル: test_notaskbar.py プロジェクト: ifwe/wxpy
import wx
from testutil import main

def test_notaskbar():
    f = lambda: wx.Frame(None, -1, style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_NO_TASKBAR)

    frames = [f() for x in xrange(10)]
    for frame in frames:
        frame.Destroy()



if __name__ == '__main__':
    main(test_notaskbar)