Esempio n. 1
0
 def test_monitorServices_handles_scan_failure(self):
     clock = Clock()
     service = ActiveDiscoveryService(clock)
     self.patch(service, "refreshDiscoveryConfig")
     scanIfNeeded = self.patch(service, "scanIfNeeded")
     scanIfNeeded.side_effect = Exception
     # Pretend the call to refreshDiscoveryConfig enabled discovery,
     # as expected.
     service.discovery_enabled = True
     with TwistedLoggerFixture() as logger:
         service.run()
     self.assertThat(
         logger.output, DocTestMatches(dedent("""\
             ...: periodic scan failed.
             Traceback (most recent call last):
             ...""")))
Esempio n. 2
0
 def test_scanIfNeeded_logs_success(self):
     service = ActiveDiscoveryService(Clock())
     try_lock_and_scan = self.patch(service, "try_lock_and_scan")
     try_lock_and_scan.return_value = "happy"
     service.discovery_enabled = True
     service.discovery_last_scan = 0
     service.discovery_interval = 1
     service.startService()
     with TwistedLoggerFixture() as logger:
         yield service.run()
     self.assertThat(logger.output,
                     DocTestMatches("...Active network discovery: happy"))