'Test advertising via BonJour'

@skipIf(is_ci, u'Continuous    Integration    servers    do    not    support    BonJour')
def test_bonjour(self):

    from calibre.srv.bonjour import BonJour
    from calibre.utils.Zeroconf import Zeroconf
    b = BonJour()
    with TestServer((lambda data: (data.path[0] + data.read())), plugins=(b,), shutdown_timeout=5) as server:
        self.assertTrue(b.started.wait(5), u'BonJour    not    started')
        self.ae(b.advertised_port, server.address[1])
        service = b.services[0]
        self.ae(service.type, '_calibre._tcp.local.')
        r = Zeroconf()
        info = r.getServiceInfo(service.type, service.name)
        self.assertIsNotNone(info)
        self.ae(info.text, '\npath=/opds')
    self.assertTrue(b.stopped.wait(5), u'BonJour    not    stopped')
