def test_subnet_id_many(self): kwargs = {"subnet_id": [3, 4, 5]} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 2, "1": 1}) self.assertEqual(output["unused"], {"0": 253 * 2, "1": 253})
def get_ip_availability(self, **kwargs): return ip_availability.get_ip_availability(**kwargs)
def test_ip_version_many(self): kwargs = {"ip_version": [4, 6]} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 4, "1": 4}) self.assertEqual(output["unused"], {"0": 253 * 4, "1": 253 * 4})
def test_subnet_id_specific(self): kwargs = {"subnet_id": 3} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"1": 1}) self.assertEqual(output["unused"], {"1": 253})
def test_segment_id_many(self): kwargs = {"segment_id": [0, 1]} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 4, "1": 4}) self.assertEqual(output["unused"], {"0": 253 * 4, "1": 253 * 4})
def test_ip_version_6(self): kwargs = {"ip_version": 6} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 2, "1": 2}) self.assertEqual(output["unused"], {"0": 253 * 2, "1": 253 * 2})
def test_network_id_specific(self): kwargs = {"network_id": 0} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 2, "1": 2}) self.assertEqual(output["unused"], {"0": 253 * 2, "1": 253 * 2})
def test_segment_id_specific(self): kwargs = {"segment_id": 0} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 4}) self.assertEqual(output["unused"], {"0": 253 * 4})
def test_with_ip_policy(self, utcnow_patch): self._with_ip_policy(utcnow_patch) output = ip_avail.get_ip_availability(**self.default_kwargs) self.assertEqual(output["used"], {"region-cell": 50}) self.assertEqual(output["unused"], {"region-cell": 254 * 72 - 50})
def test_all_None(self): kwargs = {} output = ip_avail.get_ip_availability(**kwargs) self.assertEqual(output["used"], {"0": 4, "1": 4}) self.assertEqual(output["unused"], {"0": 253 * 4, "1": 253 * 4})
def test_no_ip_addresses_no_ip_policy(self): self._no_ip_addresses_no_ip_policy() output = ip_avail.get_ip_availability(**self.default_kwargs) self.assertEqual(output["used"], {"region-cell": 0}) self.assertEqual(output["unused"], {"region-cell": 256})
def test_do_not_use_1(self): self._do_not_use_1() output = ip_avail.get_ip_availability(**self.default_kwargs) self.assertEqual(output["used"], dict()) self.assertEqual(output["unused"], dict())
def test_do_not_use_None(self): self._do_not_use_None() output = ip_avail.get_ip_availability(**self.default_kwargs) self.assertEqual(output["used"], {"region-cell": 1}) self.assertEqual(output["unused"], {"region-cell": 253})
def test_empty(self): output = ip_avail.get_ip_availability(**self.default_kwargs) self.assertEqual(output["used"], {}) self.assertEqual(output["unused"], {})