mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #1039 from hellbot/srv-rdata
rdata_text for SrvValue
This commit is contained in:
@@ -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__())
|
||||
|
||||
|
||||
@@ -141,6 +141,16 @@ 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.'})
|
||||
|
||||
Reference in New Issue
Block a user