Esempio n. 1
0
    def test_01_add_remove(self):
        a = PortsAllocator(minimum=22000, increment=2, maximum=22010)

        # value = 2000; value < 2012; value += 2
        for value in xrange(22000, 22012, 2):
            self._tst(value, a.allocate())
        try:
            value = a.allocate()
        except PortsAllocatorError, e:
            pass
Esempio n. 2
0
    def test_01_add_remove(self):
        a = PortsAllocator(minimum=22000, increment=2, maximum=22010)

        # value = 2000; value < 2012; value += 2
        for value in xrange(22000, 22012, 2):
            self._tst(value, a.allocate())
        try:
            value = a.allocate()
        except PortsAllocatorError, e:
            pass
Esempio n. 3
0
    def test_03_allocate_busy_port(self):
        # let's use a port
        PORT = 31000
        listener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # SOCK_DGRAM ?
        listener.bind(("localhost", PORT)) # socket.gethostname()

        a = PortsAllocator(minimum=PORT, increment=2, maximum=PORT + 100)
        num = a.allocate()
        self._tst(PORT + 2, num)
        # that should have worked
        listener.close()
Esempio n. 4
0
    def test_03_allocate_busy_port(self):
        # let's use a port
        PORT = 31000
        listener = socket.socket(socket.AF_INET,
                                 socket.SOCK_DGRAM)  # SOCK_DGRAM ?
        listener.bind(("localhost", PORT))  # socket.gethostname()

        a = PortsAllocator(minimum=PORT, increment=2, maximum=PORT + 100)
        num = a.allocate()
        self._tst(PORT + 2, num)
        # that should have worked
        listener.close()
Esempio n. 5
0
 def test_02_add_many(self):
     a = PortsAllocator(minimum=22000, increment=2, maximum=22010)
     values = a.allocate_many(6)
     a.free_many(values)
     values = a.allocate_many(3)
     values = a.allocate_many(3)
     try:
         value = a.allocate()
     except PortsAllocatorError, e:
         pass
Esempio n. 6
0
 def test_02_add_many(self):
     a = PortsAllocator(minimum=22000, increment=2, maximum=22010)
     values = a.allocate_many(6)
     a.free_many(values)
     values = a.allocate_many(3)
     values = a.allocate_many(3)
     try:
         value = a.allocate()
     except PortsAllocatorError, e:
         pass