本文整理汇总了Python中mozdns.address_record.models.AddressRecord.label方法的典型用法代码示例。如果您正苦于以下问题:Python AddressRecord.label方法的具体用法?Python AddressRecord.label怎么用?Python AddressRecord.label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozdns.address_record.models.AddressRecord
的用法示例。
在下文中一共展示了AddressRecord.label方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_update_to_existing
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import label [as 别名]
def test_invalid_update_to_existing(self):
rec1 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str="128.193.40.1", ip_type='4')
rec2 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str="128.193.40.2", ip_type='4')
rec3 = AddressRecord(label='foo', domain=self.z_o_e,
ip_str="128.193.40.1", ip_type='4')
rec3.save()
rec2.save()
rec1.save()
rec1.label = "foo"
self.assertRaises(ValidationError, rec1.save)
rec3.label = "bar"
self.assertRaises(ValidationError, rec3.save)
osu_block = "633:105:F000:"
rec1 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str=osu_block + ":1", ip_type='6')
rec2 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str=osu_block + ":2", ip_type='6')
rec3 = AddressRecord(label='foo', domain=self.z_o_e,
ip_str=osu_block + ":1", ip_type='6')
rec1.save()
rec2.save()
rec3.save()
rec2.ip_str = osu_block + ":1"
self.assertRaises(ValidationError, rec2.save)
rec3.label = 'bar'
self.assertRaises(ValidationError, rec3.save)
示例2: test_no_update_when_glue
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import label [as 别名]
def test_no_update_when_glue(self):
"""A record shouldn't update it's label or domain when it is a glue
record"""
label = 'ns99'
glue = AddressRecord(label=label, domain=self.o_e,
ip_str='128.193.1.10', ip_type='4')
glue.save()
server = "%s.%s" % (label, self.o_e)
ns = Nameserver(domain=self.o_e, server=server)
ns.save()
self.assertTrue(ns.glue == glue)
# Shouldn't be able to edit label or domain.
glue.label = "ns100"
self.assertRaises(ValidationError, glue.save)
glue.domain = self.m_o_e
self.assertRaises(ValidationError, glue.save)
glue = AddressRecord.objects.get(pk=glue.pk)
glue.label = "ns101"
glue.domain = self.e
self.assertRaises(ValidationError, glue.save)
# Ip can change.
glue = AddressRecord.objects.get(pk=glue.pk)
glue.ip_str = "192.192.12.12"
glue.save()
示例3: test_disallow_name_update_of_glue_A
# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import label [as 别名]
def test_disallow_name_update_of_glue_A(self):
# Glue records should not be allowed to change their name.
glue = AddressRecord(label='ns39', domain=self.f_r, ip_str=
'128.193.1.77', ip_type='4')
glue.clean()
glue.save()
data = {'domain': self.f_r, 'server': 'ns39.foo.ru'}
ns = self.do_add(**data)
self.assertTrue(ns.glue)
self.assertEqual(ns.glue, glue)
glue.label = "ns22"
self.assertRaises(ValidationError, glue.clean)