def parse(self, name: str, data: str, ttl: int) -> DNSRecordBase: from pypdnsrest.dnsrecords import DNSMxRecord from pypdnsrest.dnsrecords import DNSMxRecordData tmp = data.split(" ") d = DNSMxRecordData(priority=int(tmp[0]), server=tmp[1]) rec = DNSMxRecord(name, timedelta(seconds=ttl)) rec.set_data(d) return rec
def test_add_mx_record(self): from pypdnsrest.dnsrecords import DNSMxRecord from pypdnsrest.dnsrecords import DNSMxRecordData mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10) rec = DNSMxRecord(self.zone) rec.set_data(mxdata) z = DNSZone() self.assertTrue(z.add_record(rec))
def test_record(self): mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10) rec = DNSMxRecord(self.zone) self.assertTrue(rec.set_data(mxdata))
def test_invalid_priority_type(self): mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), u"invalid") rec = DNSMxRecord(self.zone) with self.assertRaises(InvalidDNSRecordException) as context: rec.set_data(mxdata)
def test_invalid_server(self): mxdata = DNSMxRecordData(u"invalid", 10) rec = DNSMxRecord(self.zone) with self.assertRaises(InvalidDNSRecordException) as context: rec.set_data(mxdata)
def test_record_wrong_priority(self): mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), -1) rec = DNSMxRecord(self.zone) with self.assertRaises(InvalidDNSRecordException) as context: rec.set_data(mxdata)
def test_record2(self): mxdata = DNSMxRecordData(u"mail.{0}".format(self.zone), 10, timedelta(hours=1)) rec = DNSMxRecord(self.zone) self.assertTrue(rec.set_data(mxdata))