示例#1
0
 def test_bogus_requests_releases(self):
     """Requests twice or release twice"""
     s = SlotsProvider(10)
     s.request("eth1", "192.168.1.10")
     with self.assertRaises(ValueError):
         s.request("eth1", "192.168.1.10")
     self.assertEqual(s.request("eth1", "192.168.1.11"), 1)
     s.release("192.168.1.10")
     with self.assertRaises(ValueError):
         s.release("192.168.1.10")
     with self.assertRaises(ValueError):
         s.get("192.168.1.10")
示例#2
0
 def test_bogus_requests_releases(self):
     """Requests twice or release twice"""
     s = SlotsProvider(10)
     s.request("eth1", "192.168.1.10")
     with self.assertRaises(ValueError):
         s.request("eth1", "192.168.1.10")
     self.assertEqual(s.request("eth1", "192.168.1.11"), 1)
     s.release("192.168.1.10")
     with self.assertRaises(ValueError):
         s.release("192.168.1.10")
     with self.assertRaises(ValueError):
         s.get("192.168.1.10")
示例#3
0
 def test_requests(self):
     """Request a slot"""
     s = SlotsProvider(10)
     self.assertEqual(s.request("eth1", "192.168.1.1"), 0)
     self.assertEqual(s.request("eth1", "192.168.1.2"), 1)
     self.assertEqual(s.request("eth1", "192.168.1.3"), 2)
     self.assertEqual(s.request("eth3", "192.168.1.4"), 0)
     self.assertEqual(s.request("eth3", "192.168.1.5"), 1)
     self.assertEqual(s.get("192.168.1.5"), 1)
示例#4
0
 def test_requests(self):
     """Request a slot"""
     s = SlotsProvider(10)
     self.assertEqual(s.request("eth1", "192.168.1.1"), 0)
     self.assertEqual(s.request("eth1", "192.168.1.2"), 1)
     self.assertEqual(s.request("eth1", "192.168.1.3"), 2)
     self.assertEqual(s.request("eth3", "192.168.1.4"), 0)
     self.assertEqual(s.request("eth3", "192.168.1.5"), 1)
     self.assertEqual(s.get("192.168.1.5"), 1)