本文整理汇总了Python中mozdns.address_record.models.AddressRecord.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python AddressRecord.full_clean方法的具体用法?Python AddressRecord.full_clean怎么用?Python AddressRecord.full_clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozdns.address_record.models.AddressRecord
的用法示例。
在下文中一共展示了AddressRecord.full_clean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import full_clean [as 别名]
def test1(self):
ip_start = "10.0.0.10"
ip_end = "10.0.0.19"
ptr = PTR(name="foo.mz", ip_str="10.0.0.15", ip_type='4')
ptr.full_clean()
ptr.save()
a = AddressRecord(
label="foo", domain=self.domain, ip_str="10.0.0.16", ip_type='4')
a.full_clean()
a.save()
istart, iend, ipf_q = start_end_filter(ip_start, ip_end, '4')
addrs = list(AddressRecord.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
ptrs = list(PTR.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
intrs = list(StaticInterface.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
self.assertEqual(a.pk, addrs[0].pk)
self.assertEqual(ptr.pk, ptrs[0].pk)
self.assertFalse(intrs)
range_details = range_usage(ip_start, ip_end, '4')
self.assertEqual(8, range_details['unused'])
self.assertEqual(2, range_details['used'])
self.assertEqual([(int(istart), int(istart) + 4),
(int(istart) + 7, int(istart) + 9)],
range_details['free_ranges'])
示例2: test2
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import full_clean [as 别名]
def test2(self):
ip_start = "10.0.1.0"
ip_end = "10.0.1.99"
ptr = PTR(name="foo.mz", ip_str="10.0.1.3", ip_type="4")
ptr.full_clean()
ptr.save()
a = AddressRecord(label="foo", domain=self.domain, ip_str="10.0.1.3", ip_type="4")
a.full_clean()
a.save()
s = create_fake_host(hostname="foo.mozilla.com")
s.save()
sreg = StaticReg.objects.create(label="foo", domain=self.domain, ip_str="10.0.1.4", ip_type="4", system=s)
istart, iend, ipf_q = start_end_filter(ip_start, ip_end, "4")
addrs = list(AddressRecord.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
ptrs = list(PTR.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
sregs = list(StaticReg.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
self.assertEqual(a.pk, addrs[0].pk)
self.assertEqual(ptr.pk, ptrs[0].pk)
self.assertEqual(sreg.pk, sregs[0].pk)
range_details = range_usage(ip_start, ip_end, "4")
self.assertEqual(98, range_details["unused"])
self.assertEqual(2, range_details["used"])
self.assertEqual(
[(int(istart) + 0, int(istart) + 2), (int(istart) + 5, int(istart) + 99)], range_details["free_ranges"]
)
示例3: test2
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import full_clean [as 别名]
def test2(self):
ip_start = "10.0.1.0"
ip_end = "10.0.1.99"
ptr = PTR(name="foo.mz", ip_str="10.0.1.3", ip_type='4')
ptr.full_clean()
ptr.save()
a = AddressRecord(label="foo", domain=self.domain, ip_str="10.0.1.3",
ip_type='4')
a.full_clean()
a.save()
s = System()
s.save()
intr = StaticInterface(
label="foo", domain=self.domain, ip_str="10.0.1.4",
ip_type='4', system=s, mac="00:11:22:33:44:55")
intr.full_clean()
intr.save()
istart, iend, ipf_q = start_end_filter(ip_start, ip_end, '4')
addrs = list(AddressRecord.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
ptrs = list(PTR.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
intrs = list(StaticInterface.objects.filter(ipf_q).
order_by('ip_lower').order_by('ip_upper'))
self.assertEqual(a.pk, addrs[0].pk)
self.assertEqual(ptr.pk, ptrs[0].pk)
self.assertEqual(intr.pk, intrs[0].pk)
range_details = range_usage(ip_start, ip_end, '4')
self.assertEqual(98, range_details['unused'])
self.assertEqual(2, range_details['used'])
self.assertEqual([(int(istart) + 0, int(istart) + 2),
(int(istart) + 5, int(istart) + 99)],
range_details['free_ranges'])