本文整理汇总了Python中mozdns.domain.models.Domain.save方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.save方法的具体用法?Python Domain.save怎么用?Python Domain.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozdns.domain.models.Domain
的用法示例。
在下文中一共展示了Domain.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_delete
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_bad_delete(self):
network = "129.0.0.0"
prefixlen = "24"
kwargs = {'network': network, 'prefixlen': prefixlen, 'ip_type': '4'}
s = self.do_basic_add(**kwargs)
s_pk = s.pk
self.assertTrue(s)
d = Domain(name="asdf")
d.save()
start_str = "129.0.0.1"
end_str = "129.0.0.255"
network = s
r = Range(start_str=start_str, end_str=end_str, network=network)
r.clean()
r.save()
self.assertEqual(r.network, s)
self.assertTrue(len(s.range_set.all()) == 1)
self.assertRaises(ValidationError, s.delete)
self.assertTrue(Network.objects.get(pk=s_pk))
r.delete()
s.delete()
self.assertEqual(len(Network.objects.filter(pk=s_pk)), 0)
示例2: DeleteStaticStaticRegTests
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
class DeleteStaticStaticRegTests(TestCase):
def create_domain(self, name, ip_type=None, delegated=False):
if ip_type is None:
ip_type = '4'
if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
pass
else:
name = ip_to_domain_name(name, ip_type=ip_type)
d = Domain(name=name, delegated=delegated)
d.clean()
self.assertTrue(d.is_reverse)
return d
def setUp(self):
self.arpa = self.create_domain(name='arpa')
self.arpa.save()
self.i_arpa = self.create_domain(name='in-addr.arpa')
self.i_arpa.save()
self.c = Domain(name="ccc")
self.c.save()
self.f_c = Domain(name="foo.ccc")
self.f_c.save()
self.r1 = self.create_domain(name="10")
self.r1.save()
self.n = create_fake_host(hostname="foo.mozilla.com")
self.n.clean()
self.n.save()
View.objects.get_or_create(name="private")
def do_add(self, label, domain, ip_str, system, ip_type='4'):
r = StaticReg(
label=label, domain=domain, ip_str=ip_str,
ip_type=ip_type, system=system
)
r.clean()
r.save()
return r
def do_delete(self, r):
ip_str = r.ip_str
fqdn = r.fqdn
r.delete()
self.assertFalse(
AddressRecord.objects.filter(ip_str=ip_str, fqdn=fqdn))
def test1_delete_basic(self):
# Does deleting a system delete it's interfaces?
label = "foo"
domain = self.f_c
ip_str = "10.0.0.2"
system = create_fake_host(hostname="foo")
system.save()
kwargs = {
'label': label, 'domain': domain, 'ip_str': ip_str,
'system': system}
self.do_add(**kwargs)
self.assertTrue(StaticReg.objects.filter(**kwargs))
system.delete()
self.assertFalse(StaticReg.objects.filter(**kwargs))
示例3: test_cleanup_cname
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_cleanup_cname(self):
# Make sure CNAME record block
c = Domain(name='foo1')
c.save()
self.assertFalse(c.purgeable)
f_c = create_fake_zone('foo.foo1', suffix="")
self.assertEqual(f_c.name, 'foo.foo1')
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="z.foo.foo1"))
self.assertTrue(Domain.objects.filter(name="foo.foo1"))
self.assertFalse(f_c.purgeable)
fqdn = "cname.x.y.z.foo.foo1"
label, the_domain = ensure_label_domain(fqdn)
cname = CNAME(label=label, domain=the_domain, target="foo")
cname.save()
self.assertFalse(prune_tree(the_domain))
cname.delete()
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="z.foo.foo1"))
fqdn = "bar.x.y.z.foo.poo"
self.assertTrue(Domain.objects.filter(name="foo.foo1"))
示例4: CNAMEStaticRegTests
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
class CNAMEStaticRegTests(TestCase):
def create_domain(self, name, ip_type=None, delegated=False):
if ip_type is None:
ip_type = '4'
if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
pass
else:
name = ip_to_domain_name(name, ip_type=ip_type)
d = Domain(name=name, delegated=delegated)
d.clean()
self.assertTrue(d.is_reverse)
return d
def setUp(self):
self.arpa = self.create_domain(name='arpa')
self.arpa.save()
self.i_arpa = self.create_domain(name='in-addr.arpa')
self.i_arpa.save()
self.c = Domain(name="ccc")
self.c.save()
self.f_c = Domain(name="foo.ccc")
self.f_c.save()
self.r1 = self.create_domain(name="10")
self.r1.save()
self.n = System()
self.n.clean()
self.n.save()
def do_add_intr(self, mac, label, domain, ip_str, ip_type='4'):
r = StaticInterface(mac=mac, label=label, domain=domain, ip_str=ip_str,
ip_type=ip_type, system=self.n)
r.clean()
r.save()
repr(r)
return r
def test1_delete_cname(self):
mac = "11:22:33:44:55:66"
label = "foo4"
domain = self.f_c
ip_str = "10.0.0.2"
kwargs = {'mac': mac, 'label': label, 'domain': domain,
'ip_str': ip_str}
i = self.do_add_intr(**kwargs)
cn, _ = CNAME.objects.get_or_create(label='foo', domain=domain,
target=label + "." + domain.name)
self.assertRaises(ValidationError, i.delete)
def test1_delete_override(self):
mac = "12:22:33:44:55:66"
label = "foo6"
domain = self.f_c
ip_str = "10.0.0.2"
kwargs = {'mac': mac, 'label': label, 'domain': domain,
'ip_str': ip_str}
i = self.do_add_intr(**kwargs)
cn, _ = CNAME.objects.get_or_create(label='food', domain=domain,
target=label + "." + domain.name)
i.delete(check_cname=False)
示例5: test_update_has_child_domain
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_update_has_child_domain(self):
Domain(name='com99').save()
f_c = Domain(name='foo.com99')
f_c.save()
Domain(name='boo.foo.com99').save()
f_c.name = 'foobar.com99'
self.assertRaises(ValidationError, f_c.save)
示例6: test_delegation_add_domain
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_delegation_add_domain(self):
name = "boom1"
dom = Domain(name=name, delegated=True)
dom.save()
name = "boom.boom1"
dom = Domain(name=name, delegated=False)
self.assertRaises(ValidationError, dom.save)
示例7: test_remove_domain
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_remove_domain(self):
c = Domain(name='com')
c.save()
f_c = Domain(name='foo.com')
f_c.save()
f_c.delete()
foo = Domain(name='foo.com')
str(foo)
foo.__repr__()
示例8: SSHFPTests
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
class SSHFPTests(TestCase):
def setUp(self):
self.o = Domain(name="org")
self.o.save()
self.o_e = Domain(name="mozilla.org")
self.o_e.save()
def do_generic_add(self, data):
sshfp = SSHFP(**data)
sshfp.__repr__()
sshfp.save()
self.assertTrue(sshfp.details())
self.assertTrue(sshfp.get_absolute_url())
self.assertTrue(sshfp.get_edit_url())
self.assertTrue(sshfp.get_delete_url())
rsshfp = SSHFP.objects.filter(**data)
self.assertEqual(len(rsshfp), 1)
return sshfp
def do_remove(self, data):
sshfp = self.do_generic_add(data)
sshfp.delete()
rmx = SSHFP.objects.filter(**data)
self.assertTrue(len(rmx) == 0)
def test_add_remove_sshfp(self):
label = "asdf"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "asdk"
key = "eee85bca3608ac860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "df"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "12314"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
示例9: test_basic_add_remove2
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_basic_add_remove2(self):
# MAke sure that if a domain is set to not purgeable the prune stops at
# that domain.
c = Domain(name='edu')
c.save()
self.assertFalse(c.purgeable)
f_c = Domain(name='foo.edu')
s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
description="foo.edu")
f_c.soa = s
f_c.save()
self.assertFalse(f_c.purgeable)
fqdn = "bar.x.y.z.foo.edu"
label, the_domain = ensure_label_domain(fqdn)
self.assertEqual(label, "bar")
self.assertEqual(the_domain.name, "x.y.z.foo.edu")
self.assertTrue(the_domain.purgeable)
self.assertEqual(the_domain.master_domain.name, "y.z.foo.edu")
self.assertTrue(the_domain.master_domain.purgeable)
self.assertEqual(
the_domain.master_domain.master_domain.name, "z.foo.edu")
self.assertTrue(the_domain.master_domain.master_domain.purgeable)
self.assertEqual(
the_domain.master_domain.master_domain.master_domain.name,
"foo.edu")
self.assertFalse(
the_domain.master_domain.master_domain.master_domain.purgeable)
# See if purgeable stops prune
the_domain.purgeable = False
the_domain.save()
self.assertFalse(prune_tree(the_domain))
the_domain.purgeable = True
the_domain.save()
# Ok, reset
y_z = Domain.objects.get(name="y.z.foo.edu")
y_z.purgeable = False
y_z.save()
# Refresh the domain
the_domain = Domain.objects.get(pk=the_domain.pk)
# This should delete up to and stop at the domain "y.z.foo.edu"
self.assertTrue(prune_tree(the_domain))
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.edu"))
self.assertTrue(Domain.objects.filter(name="y.z.foo.edu"))
self.assertTrue(Domain.objects.filter(name="z.foo.edu"))
self.assertTrue(Domain.objects.filter(name="foo.edu"))
# If we delete y.z.foo.com and then call prune on z.foo.com is should
# delete z.foo.com
Domain.objects.get(name="y.z.foo.edu").delete()
self.assertTrue(prune_tree(Domain.objects.get(name="z.foo.edu")))
self.assertFalse(Domain.objects.filter(name="z.foo.edu"))
self.assertTrue(Domain.objects.filter(name="foo.edu"))
示例10: test_remove_has_child_records
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_remove_has_child_records(self):
Domain(name='com').save()
f_c = Domain(name='foo.com')
f_c.save()
cn = CNAME(domain=f_c, label="no", target="asdf")
cn.full_clean()
cn.save()
self.assertRaises(ValidationError, f_c.delete)
示例11: test_delete_with_domains
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_delete_with_domains(self):
data = {'primary': "ns1asfdadsf.foo.com", 'contact': "email.foo.com"}
soa = SOA(**data)
soa.save()
d0 = Domain(name='com')
d0.save()
d1 = Domain(name='foo.com', soa=soa)
d1.soa = soa
d1.save()
self.assertRaises(ValidationError, soa.delete)
示例12: test_add_address_underscore_in_name_domain
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_add_address_underscore_in_name_domain(self):
d = Domain(name="_mssucks.edu")
d.save()
data = {'label': '*', 'domain': d, 'ip': "128.193.0.10"}
self.do_add_record(data)
data = {'label': 'foo', 'domain': d, 'ip': "128.193.0.10"}
a = self.do_add_record(data)
a.save()
data = {'label': 'noop', 'domain': d, 'ip': "128.193.0.10"}
self.do_add_record(data)
示例13: build_sample_domain
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def build_sample_domain():
domain_name = ''
for i in range(2):
domain_name = random_label()
domain = Domain(name=domain_name)
soa = SOA(
primary=random_label(), contact="asf", description=random_label())
soa.save()
domain.soa = soa
domain.save()
return domain
示例14: test_no_soa_block
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
def test_no_soa_block(self):
fqdn = "baz.bar.foo.eu"
self.assertRaises(ValidationError, ensure_label_domain, fqdn)
c = Domain(name='eu')
c.save()
self.assertFalse(c.purgeable)
f_c = Domain(name='foo.eu')
f_c.save()
self.assertFalse(f_c.purgeable)
# Even with domains there, they aren't part of a zone and should so
# creation should fail.
self.assertRaises(ValidationError, ensure_label_domain, fqdn)
示例15: TXTTests
# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import save [as 别名]
class TXTTests(TestCase):
def setUp(self):
self.o = Domain(name="org")
self.o.save()
self.o_e = Domain(name="oregonstate.org")
self.o_e.save()
def do_generic_add(self, data):
txt = TXT(**data)
txt.__repr__()
txt.save()
self.assertTrue(txt.details())
self.assertTrue(txt.get_absolute_url())
self.assertTrue(txt.get_edit_url())
self.assertTrue(txt.get_delete_url())
rtxt = TXT.objects.filter(**data)
self.assertTrue(len(rtxt) == 1)
return txt
def do_remove(self, data):
txt = self.do_generic_add(data)
txt.delete()
rmx = TXT.objects.filter(**data)
self.assertTrue(len(rmx) == 0)
def test_add_remove_txt(self):
label = "asdf"
data = "asdf"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "asdf"
data = "asdfasfd"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "df"
data = "aasdf"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "12314"
data = "dd"
data = {'label': label, 'txt_data': data, 'domain': self.o}
self.do_generic_add(data)
def test_bad_data(self):
label = "asdf"
data = '"dfa f'
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.assertRaises(ValidationError, self.do_generic_add, data)