Esempio n. 1
0
 def test__returns_expected_last_scan(self):
     expected_last_scan = random.randint(1, 1000)
     Config.objects.set_config("active_discovery_last_scan",
                               expected_last_scan)
     service = ActiveDiscoveryService(Clock())
     enabled, interval, last_scan = service.get_active_discovery_config()
     self.assertThat(last_scan, Equals(expected_last_scan))
Esempio n. 2
0
 def test__returns_expected_interval(self):
     expected_interval = random.randint(1, 1000)
     Config.objects.set_config("active_discovery_interval",
                               expected_interval)
     service = ActiveDiscoveryService(Clock())
     enabled, interval, last_scan = service.get_active_discovery_config()
     self.assertThat(interval, Equals(expected_interval))
     # Enabled is True if interval is > 0
     self.assertThat(enabled, Equals(True))
Esempio n. 3
0
 def test__returns_disabled_if_interval_is_zero(self):
     expected_interval = 0
     expected_last_scan = 0
     Config.objects.set_config("active_discovery_last_scan",
                               expected_last_scan)
     Config.objects.set_config("active_discovery_interval",
                               expected_interval)
     service = ActiveDiscoveryService(Clock())
     enabled, interval, last_scan = service.get_active_discovery_config()
     self.assertThat(enabled, Equals(False))
Esempio n. 4
0
 def test__returns_disabled_if_interval_is_invalid(self):
     expected_interval = factory.make_name()
     expected_last_scan = factory.make_name()
     Config.objects.set_config("active_discovery_last_scan",
                               expected_last_scan)
     Config.objects.set_config("active_discovery_interval",
                               expected_interval)
     service = ActiveDiscoveryService(Clock())
     enabled, interval, last_scan = service.get_active_discovery_config()
     self.assertThat(enabled, Equals(False))
     self.assertThat(interval, Equals(0))
     self.assertThat(last_scan, Equals(0))