def test_is_free_and_reserve(self): ipm = IPManager('uuid', '192.168.1.0/24') self.assertEqual(True, ipm.is_free('192.168.1.24')) ipm.reserve('192.168.1.24', ('test', '123')) self.assertEqual(False, ipm.is_free('192.168.1.24')) self.assertEqual(False, ipm.reserve('192.168.1.24', ('test', '123'))) self.assertEqual(True, ipm.is_free('192.168.1.42')) self.assertEqual(True, ipm.reserve('192.168.1.42', ('test', '123'))) self.assertEqual(False, ipm.is_free('192.168.1.42')) ipm.release('192.168.1.42') self.assertEqual(True, ipm.is_free('192.168.1.42'))
def test_release(self, mock_time): ipm = IPManager('uuid', '192.168.1.0/24') ipm.reserve('192.168.1.10', ('test', '123')) ipm.release('10.0.0.1') ipm.release('192.168.1.10') self.assertEqual( { '192.168.1.0': { 'user': ('ipmanager', 'uuid'), 'when': 1632261535.027476 }, '192.168.1.255': { 'user': ('ipmanager', 'uuid'), 'when': 1632261535.027476 } }, ipm.in_use)