diff --git a/octodns/record/srv.py b/octodns/record/srv.py index af3797c..33e76ce 100644 --- a/octodns/record/srv.py +++ b/octodns/record/srv.py @@ -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__()) diff --git a/tests/test_octodns_record_srv.py b/tests/test_octodns_record_srv.py index 3cc39b5..e774dc5 100644 --- a/tests/test_octodns_record_srv.py +++ b/tests/test_octodns_record_srv.py @@ -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.'})