def _srv_to_urls(srv_recs, protocol=None): """Converts list of SRV records to list of URLs. """ return [ dnsutils.srv_rec_to_url(srv_rec, protocol=protocol) for srv_rec in srv_recs ]
def test_srv_rec_to_url_both(self): """Test srv_rec_to_url method with both optional arguments""" srv_target = '_protocol.x.y.z' srv_rec = ('host', 1234, None, None) proto = 'myproto' url = dnsutils.srv_rec_to_url(srv_rec, srv_target, protocol=proto) self.assertEqual(url, '{}://host:1234'.format(proto))
def _srv_to_urls(self, srv_recs, protocol=None): """Randomizes and converts SRV records to URLs.""" _LOGGER.debug('Result: %r', srv_recs) return [ dnsutils.srv_rec_to_url(srv_rec, protocol=protocol) for srv_rec in srv_recs ]
def test_srv_rec_to_url_proto(self): """Test srv_rec_to_url method with protocol argument""" srv_rec = ('host', 1234, None, None) proto = 'myproto' url = dnsutils.srv_rec_to_url(srv_rec, protocol=proto) self.assertEqual(url, '{}://host:1234'.format(proto))
def test_srv_rec_to_url_target(self): """Test srv_rec_to_url method with target name""" srv_target = '_protocol.x.y.z' srv_rec = ('host', 1234, None, None) url = dnsutils.srv_rec_to_url(srv_rec, srv_target) self.assertEqual(url, 'protocol://host:1234')
def test_srv_rec_to_url(self): """Test srv_rec_to_url method with no protocol""" srv_rec = ('host', 1234, None, None) url = dnsutils.srv_rec_to_url(srv_rec) self.assertEqual(url, '://host:1234')