Example #1
0
                def it_returns_different_ips():
                    addr_pool = net.AddrAllocator('1.2.3.0/24')

                    ip1 = addr_pool.new(12345)
                    ip2 = addr_pool.new(12346)

                    assert_that(ip1, not_(equal_to(ip2)))
Example #2
0
                def it_returns_same_ips():
                    addr_pool = net.AddrAllocator('1.2.3.0/24')

                    ip1 = addr_pool.new(12345)
                    ip2 = addr_pool.new(12345)

                    assert_that(ip1, equal_to(ip2))
Example #3
0
            def it_returns_false():
                addr_pool = net.AddrAllocator('1.2.3.252/30')
                addr_pool.new(12345)
                addr_pool.new(12346)

                more_addrs = addr_pool.has_available_addrs()

                assert_that(more_addrs, is_(False))
Example #4
0
            def it_raises_exception():
                addr_pool = net.AddrAllocator('1.2.3.252/30')
                addr_pool.new(12345)
                addr_pool.new(12346)

                assert_that(
                    calling(addr_pool.new).with_args(12347),
                    raises(net.NoAddressesAvailable))
Example #5
0
            def it_returns_first_available_ip_address():
                addr_pool = net.AddrAllocator('1.2.3.0/24')

                ip = addr_pool.new(12345)

                assert_that(ip, is_('1.2.3.2'))