def test_modify_existing_performs_validation(self): subnet = make_plain_subnet() IPRange( subnet=subnet, type=IPRANGE_TYPE.DYNAMIC, start_ip="192.168.0.100", end_ip="192.168.0.150", ).save() iprange = IPRange( subnet=subnet, type=IPRANGE_TYPE.DYNAMIC, start_ip="192.168.0.151", end_ip="192.168.0.200", ) iprange.save() # Make sure safe modification works. iprange.start_ip = "192.168.0.210" iprange.end_ip = "192.168.0.250" iprange.save() # Modify again, but conflict with first range this time. instance_id = iprange.id iprange.start_ip = "192.168.0.110" iprange.end_ip = "192.168.0.140" with ExpectedException(ValidationError, self.dynamic_overlaps): iprange.save() # Make sure original range isn't deleted after failure to modify. iprange = reload_object(iprange) self.assertEqual(iprange.id, instance_id)
def test__changing_end_ip_works(self): subnet = make_plain_subnet() iprange = IPRange( subnet=subnet, type=IPRANGE_TYPE.DYNAMIC, start_ip="192.168.0.2", end_ip="192.168.0.5", ) iprange.save() iprange.end_ip = "192.168.0.10" iprange.save()