當前位置: 首頁>>代碼示例>>Python>>正文


Python models.AddressRecord類代碼示例

本文整理匯總了Python中cyder.cydns.address_record.models.AddressRecord的典型用法代碼示例。如果您正苦於以下問題:Python AddressRecord類的具體用法?Python AddressRecord怎麽用?Python AddressRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AddressRecord類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_manual_assign_of_glue

    def test_manual_assign_of_glue(self):
        # Test that assigning a different glue record doesn't get overriden by
        # the auto assinging during the Nameserver's clean function.
        glue = StaticInterface(
            label="ns25", domain=self.f_r, ip_str="128.193.99.10", ip_type="4", system=self.s, mac="11:22:33:44:55:66"
        )
        glue.clean()
        glue.save()
        data = {"domain": self.f_r, "server": "ns25.foo.ru"}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.glue, glue)

        glue2 = AddressRecord(label="ns25", domain=self.f_r, ip_str="128.193.1.78", ip_type="4")
        glue2.clean()
        glue2.save()

        ns.clean()

        # Make sure things didn't get overriden.
        self.assertEqual(ns.glue, glue)

        ns.glue = glue2
        ns.save()
        # Refresh the object
        ns = Nameserver.objects.get(pk=ns.pk)
        # Again, Make sure things didn't get overriden.
        self.assertEqual(ns.glue, glue2)
        # Make sure we still can't delete.
        self.assertRaises(ValidationError, glue2.delete)
        self.assertRaises(ValidationError, ns.glue.delete)

        # We shuold be able to delelte the other one.
        glue.delete()
開發者ID:Ziaunys,項目名稱:chili,代碼行數:34,代碼來源:test_models.py

示例2: test_bad_nameserver_soa_state_case_3_0

    def test_bad_nameserver_soa_state_case_3_0(self):
        # This is Case 3
        root_domain = create_fake_zone("asdf30")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        soa = ns.domain.soa
        ns.domain.soa = None
        root_domain.soa = None  # Shit's getting cached
        ns.domain.save()
        soa.delete()

        # At his point we should have a domain pointed at no SOA record with no
        # records attached to it. It also has no child domains.

        # Add a record to the domain.
        a = AddressRecord(
            label='', domain=root_domain, ip_type="6", ip_str="1::")
        a.save()

        s = SOA(primary="asdf.asdf", contact="asdf.asdf", description="asdf")
        s.save()
        root_domain.soa = s

        self.assertRaises(ValidationError, root_domain.save)
開發者ID:alecdhuse,項目名稱:cyder,代碼行數:25,代碼來源:test_models.py

示例3: test_integration5_ip

    def test_integration5_ip(self):
        root_domain = create_fake_zone("wee5.wee.mozilla.com", "")
        create_fake_zone("10.in-addr.arpa", "")
        res, error = self.search("10.in-addr.arpa OR "
                                       "wee5.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 2)
        self.assertEqual(len(res['NS']), 2)
        self.assertEqual(len(res['DOMAIN']), 2)
        ptr = PTR(name="host1.wee2.wee.mozilla.com", ip_str="10.0.0.1",
                  ip_type="4")
        ptr.save()
        addr = AddressRecord(label="host1", domain=root_domain,
                             ip_str="10.0.0.1", ip_type="4")
        addr.save()

        res, error = self.search(ptr.ip_str)
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 1)
        self.assertEqual(len(res['A']), 1)

        res, error = self.search("10.0.0.2")
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 0)
        self.assertEqual(len(res['A']), 0)
開發者ID:alecdhuse,項目名稱:cyder,代碼行數:25,代碼來源:test_dns.py

示例4: test_no_update_when_glue

    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()
開發者ID:Ziaunys,項目名稱:chili,代碼行數:27,代碼來源:test_models.py

示例5: do_remove_AAAA_record

    def do_remove_AAAA_record(self, aname, domain, ip ):
        aret = AddressRecord( label = aname, domain=domain, ip_str=ip, ip_type='6')
        aret.save()
        self.assertTrue(aret)

        aret.delete()

        nret  = AddressRecord.objects.filter( label = aname, domain = domain, ip_str = ip)
        self.assertFalse(nret)
開發者ID:ngokevin,項目名稱:cyder,代碼行數:9,代碼來源:tests.py

示例6: test_update_glue_to_no_glue

    def test_update_glue_to_no_glue(self):
        glue = AddressRecord(label="ns3", domain=self.r, ip_str="128.193.1.10", ip_type="4")
        glue.save()
        data = {"domain": self.r, "server": "ns3.ru"}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)

        ns.server = "ns4.wee"
        ns.save()
        self.assertTrue(ns.glue is None)
開發者ID:Ziaunys,項目名稱:chili,代碼行數:10,代碼來源:test_models.py

示例7: test_update_glue_to_no_glue

    def test_update_glue_to_no_glue(self):
        glue = AddressRecord( label='ns3', domain = self.r, ip_str = '128.193.1.10', ip_type='4' )
        glue.save()
        data = { 'domain':self.r , 'server':'ns3.ru' }
        ns = self.do_add( **data )
        self.assertTrue( ns.glue )

        ns.server = "ns4.wee"
        ns.save()
        self.assertTrue( ns.glue == None )
開發者ID:ngokevin,項目名稱:cyder,代碼行數:10,代碼來源:tests.py

示例8: test_delete_ns

    def test_delete_ns(self):
        glue = AddressRecord( label='ns4', domain = self.f_r, ip_str = '128.196.1.10', ip_type='4' )
        glue.save()
        data = { 'domain':self.f_r , 'server':'ns4.foo.ru' }
        ns = self.do_add( **data )
        self.assertTrue( ns.glue )
        self.assertEqual( ns.server, ns.glue.fqdn )

        ns.delete()
        nsret = Nameserver.objects.filter( server = 'ns2.foo.ru', domain = self.f_r )
        self.assertFalse( nsret )
開發者ID:ngokevin,項目名稱:cyder,代碼行數:11,代碼來源:tests.py

示例9: test_delete_ns

    def test_delete_ns(self):
        glue = AddressRecord(label="ns4", domain=self.f_r, ip_str="128.196.1.10", ip_type="4")
        glue.save()
        data = {"domain": self.f_r, "server": "ns4.foo.ru"}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.server, ns.glue.fqdn)

        ns.delete()
        nsret = Nameserver.objects.filter(server="ns2.foo.ru", domain=self.f_r)
        self.assertFalse(nsret)
開發者ID:Ziaunys,項目名稱:chili,代碼行數:11,代碼來源:test_models.py

示例10: test_basic_add_remove9

    def test_basic_add_remove9(self):
        # Make sure all record types block
        f_c = create_fake_zone("foo.foo22", suffix="")
        self.assertFalse(f_c.purgeable)
        fqdn = "y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label, domain=the_domain,
                             ip_type='4', ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))

        f_c = create_fake_zone("y.z.foo.foo22", suffix="")
        self.assertFalse(f_c.purgeable)
開發者ID:alecdhuse,項目名稱:cyder,代碼行數:13,代碼來源:full_name.py

示例11: test_existing_record_new_domain

    def test_existing_record_new_domain(self):
        name = "bo"
        b_dom,_ = Domain.objects.get_or_create( name = name, delegated=False )

        name = "to.bo"
        t_dom,_ = Domain.objects.get_or_create( name = name, delegated=False )

        arec1 = AddressRecord(label="no", domain=t_dom, ip_str="128.193.99.9", ip_type='4')
        arec1.save()

        name = "no.to.bo"
        n_dom = Domain( name = name, delegated=False )
        self.assertRaises(ValidationError, n_dom.save)
開發者ID:osunws,項目名稱:cyder,代碼行數:13,代碼來源:tests.py

示例12: test_invalid_create

    def test_invalid_create(self):
        glue = AddressRecord( label='ns2', domain = self.r, ip_str = '128.193.1.10', ip_type = '4' )
        glue.save()

        data = { 'domain':self.r , 'server':'ns2 .ru' }
        self.assertRaises( ValidationError, self.do_add, **data )
        data = { 'domain':self.r , 'server':'ns2$.ru' }
        self.assertRaises( ValidationError, self.do_add, **data )
        data = { 'domain':self.r , 'server':'ns2..ru' }
        self.assertRaises( ValidationError, self.do_add, **data )
        data = { 'domain':self.r , 'server':'ns2.ru ' }
        self.assertRaises( ValidationError, self.do_add, **data )
        data = { 'domain':self.r , 'server':'' }
        self.assertRaises( ValidationError, self.do_add, **data )
開發者ID:ngokevin,項目名稱:cyder,代碼行數:14,代碼來源:tests.py

示例13: test_invalid_create

    def test_invalid_create(self):
        glue = AddressRecord(label="ns2", domain=self.r, ip_str="128.193.1.10", ip_type="4")
        glue.save()

        data = {"domain": self.r, "server": "ns2 .ru"}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {"domain": self.r, "server": "ns2$.ru"}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {"domain": self.r, "server": "ns2..ru"}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {"domain": self.r, "server": "ns2.ru "}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {"domain": self.r, "server": ""}
        self.assertRaises(ValidationError, self.do_add, **data)
開發者ID:Ziaunys,項目名稱:chili,代碼行數:14,代碼來源:test_models.py

示例14: test_bad_nameserver_soa_state_case_2_0

    def test_bad_nameserver_soa_state_case_2_0(self):
        # This is Case 2
        root_domain = create_fake_zone("asdf20")
        self.assertEqual(root_domain.nameserver_set.count(), 1)
        ns = root_domain.nameserver_set.all()[0]

        # At his point we should have a domain at the root of a zone with one
        # ns record associated to the domain.

        a = AddressRecord(
            label='', domain=root_domain, ip_type="6", ip_str="1::")
        a.save()

        self.assertRaises(ValidationError, ns.delete)
開發者ID:alecdhuse,項目名稱:cyder,代碼行數:14,代碼來源:test_models.py

示例15: do_add_record

    def do_add_record(self, data):
        rec = AddressRecord(label=data['label'], domain=data['domain'],
                            ip_str=data['ip'], ip_type='4')
        rec.save()
        self.assertTrue(rec.__repr__())
        self.assertTrue(rec.details())

        search = AddressRecord.objects.filter(label=data['label'],
                    domain=data['domain'], ip_type='4', ip_str=data['ip'])
        found = False
        for record in search:
            if record.ip_str == data['ip']:
                found = True
        self.assertTrue(found)
        return rec
開發者ID:alecdhuse,項目名稱:cyder,代碼行數:15,代碼來源:test_models.py


注:本文中的cyder.cydns.address_record.models.AddressRecord類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。