Esempio n. 1
0
 def test__disables_discovery_if_interval_is_zero(self):
     expected_last_scan = random.randint(1, 1000)
     expected_interval = random.randint(1, 1000)
     yield deferToDatabase(self.set_interval, expected_interval)
     yield deferToDatabase(self.set_last_scan, expected_last_scan)
     service = ActiveDiscoveryService(Clock())
     self.patch(service, "run")
     yield service.refreshDiscoveryConfig()
     yield deferToDatabase(self.set_interval, 0)
     with TwistedLoggerFixture() as logger:
         yield service.refreshDiscoveryConfig()
     self.assertThat(logger.output,
                     DocTestMatches("...discovery is disabled..."))
     self.assertThat(service.discovery_enabled, Equals(False))
     self.assertThat(service.discovery_interval, Equals(0))
     self.assertThat(service.discovery_last_scan,
                     Equals(expected_last_scan))
Esempio n. 2
0
 def test__stores_correct_values_and_fires_timer(self):
     expected_last_scan = random.randint(1, 1000)
     expected_interval = random.randint(1, 1000)
     yield deferToDatabase(self.set_interval, expected_interval)
     yield deferToDatabase(self.set_last_scan, expected_last_scan)
     service = ActiveDiscoveryService(Clock())
     run = self.patch(service, "run")
     with TwistedLoggerFixture() as logger:
         yield service.refreshDiscoveryConfig()
     self.assertThat(logger.output,
                     DocTestMatches("...Discovery interval set to..."))
     self.assertThat(service.discovery_enabled, Equals(True))
     self.assertThat(service.discovery_interval, Equals(expected_interval))
     self.assertThat(service.discovery_last_scan,
                     Equals(expected_last_scan))
     self.assertThat(run, MockCalledOnceWith())