Пример #1
0
 def test_raises_if_not_admin(self):
     user = factory.make_User()
     handler = DiscoveryHandler(user, {}, None)
     factory.make_Discovery()
     num_discoveries = Discovery.objects.count()
     self.assertThat(num_discoveries, Equals(1))
     with ExpectedException(HandlerPermissionError):
         handler.clear()
Пример #2
0
 def test_clears_all_by_default(self):
     user = factory.make_admin()
     handler = DiscoveryHandler(user, {}, None)
     factory.make_Discovery()
     num_discoveries = Discovery.objects.count()
     self.assertThat(num_discoveries, Equals(1))
     handler.clear()
     num_discoveries = Discovery.objects.count()
     self.assertThat(num_discoveries, Equals(0))
Пример #3
0
 def test_clears_mdns_only_upon_request(self):
     user = factory.make_admin()
     handler = DiscoveryHandler(user, {}, None)
     factory.make_Discovery(hostname="useful-towel")
     num_discoveries = Discovery.objects.count()
     num_mdns = MDNS.objects.count()
     self.assertThat(num_discoveries, Equals(1))
     self.assertThat(num_mdns, Equals(1))
     handler.clear({"mdns": True})
     num_discoveries = Discovery.objects.count()
     num_mdns = MDNS.objects.count()
     self.assertThat(num_discoveries, Equals(1))
     self.assertThat(num_mdns, Equals(0))