Browse Source

rdata_text for SrvValue

Fixing #1038
pull/1039/head
Kirill Losev 2 years ago
committed by Kir
parent
commit
4c86566f82
2 changed files with 17 additions and 0 deletions
  1. +4
    -0
      octodns/record/srv.py
  2. +13
    -0
      tests/test_octodns_record_srv.py

+ 4
- 0
octodns/record/srv.py View File

@ -132,6 +132,10 @@ class SrvValue(EqualityTupleMixin, dict):
def data(self):
return self
@property
def rdata_text(self):
return f"{self.priority} {self.weight} {self.port} {self.target}"
def __hash__(self):
return hash(self.__repr__())


+ 13
- 0
tests/test_octodns_record_srv.py View File

@ -141,6 +141,19 @@ class TestRecordSrv(TestCase):
self.assertEqual(2, a.values[0].weight)
self.assertEqual(3, a.values[0].port)
self.assertEqual('srv.unit.tests.', a.values[0].target)
self.assertEqual('1 2 3 srv.unit.tests.', a.values[0].rdata_text)
# both directions should match
rdata = '1 2 3 srv.unit.tests.'
record = SrvRecord(
zone,
'_srv._tcp',
{
'ttl': 32,
'value': SrvValue.parse_rdata_text(rdata),
},
)
self.assertEqual(rdata, record.values[0].rdata_text)
def test_srv_value(self):
a = SrvValue({'priority': 0, 'weight': 0, 'port': 0, 'target': 'foo.'})


Loading…
Cancel
Save