Exemplo n.º 1
0
 def test_addresses_from_pool_wrong(self):
     name = 'SomeService'
     with self.assertRaises(ValueError):
         list(get_addresses_from_pool(name, ('localhost', 'unknown')))
     with self.assertRaises(ValueError):
         list(get_addresses_from_pool(name, ('localhost', '')))
     with self.assertRaises(ValueError):
         list(get_addresses_from_pool(name, ('localhost', object())))
Exemplo n.º 2
0
    def test_addresses_from_pool_digit(self):
        name = 'SomeService'
        address = 'localhost', 10500

        self.assertEqual((address,),
            tuple(get_addresses_from_pool(name, address)))
        self.assertEqual((address,),
            tuple(get_addresses_from_pool(name, (address[0], str(address[1])))))
        self.assertEqual((address,),
            tuple(get_addresses_from_pool(name, address, (11000, 12000))))
Exemplo n.º 3
0
    def test_addresses_from_pool_auto(self):
        name = 'SomeService'
        address = 'localhost', None

        self.assertEqual(((address[0], 0),),
            tuple(get_addresses_from_pool(name, address)))

        g = get_addresses_from_pool(name, address, (11000, 12000))
        self.assertEqual((address[0], 11538), g.next())
        self.assertEqual((address[0], 11539), g.next())
        skip(g, 99)
        self.assertEqual((address[0], 11639), g.next())
        skip(g, 12000 - 11639 - 1)
        self.assertEqual((address[0], 11000), g.next())
        skip(g, 11538 - 11000 - 2)
        self.assertEqual((address[0], 11537), g.next())
        self.assertEqual([], list(g))