Ejemplo n.º 1
0
 def test__creates_dnsdata(self):
     name = factory.make_name("dnsdata")
     (rrtype, rrdata) = factory.pick_rrset()
     dnsrr = factory.make_DNSResource(no_ip_addresses=True)
     form = DNSDataForm({
         "name": name,
         "dnsresource": dnsrr.id,
         "rrtype": rrtype,
         "rrdata": rrdata,
     })
     self.assertTrue(form.is_valid(), form.errors)
     dnsdata = form.save()
     self.assertEqual(dnsrr.id, dnsdata.dnsresource.id)
     self.assertEqual(rrtype, dnsdata.rrtype)
     self.assertEqual(rrdata, dnsdata.rrdata)
Ejemplo n.º 2
0
 def test__updates_dnsdata(self):
     dnsdata = factory.make_DNSData()
     (rrtype, rrdata) = factory.pick_rrset()
     new_ttl = random.randint(1, 1000)
     form = DNSDataForm(instance=dnsdata,
                        data={
                            "rrtype": rrtype,
                            "rrdata": rrdata,
                            "ttl": new_ttl,
                        })
     self.assertTrue(form.is_valid(), form.errors)
     form.save()
     dnsdata = reload_object(dnsdata)
     self.assertEqual(rrtype, dnsdata.rrtype)
     self.assertEqual(rrdata, dnsdata.rrdata)
     self.assertEqual(new_ttl, dnsdata.ttl)
Ejemplo n.º 3
0
 def test_accepts_ttl(self):
     name = factory.make_name("dnsdata")
     (rrtype, rrdata) = factory.pick_rrset()
     dnsrr = factory.make_DNSResource(no_ip_addresses=True)
     ttl = random.randint(1, 10000)
     form = DNSDataForm({
         "name": name,
         "dnsresource": dnsrr.id,
         "ttl": ttl,
         "rrtype": rrtype,
         "rrdata": rrdata,
     })
     self.assertTrue(form.is_valid(), form.errors)
     dnsdata = form.save()
     self.assertEqual(dnsrr.id, dnsdata.dnsresource.id)
     self.assertEqual(rrtype, dnsdata.rrtype)
     self.assertEqual(rrdata, dnsdata.rrdata)
     self.assertEqual(ttl, dnsdata.ttl)