def test__clear_logs_username_if_given(self): user = factory.make_admin() maaslog = self.patch(discovery_module.maaslog, 'info') factory.make_MDNS() factory.make_Neighbour() Discovery.objects.clear(user=user, all=True) self.assertThat( maaslog, MockCalledOnceWith( Matches(DocTestMatches("User '%s' cleared..." % user.username))))
def test__clear_neighbour_entries(self): maaslog = self.patch(discovery_module.maaslog, 'info') factory.make_MDNS() factory.make_MDNS() factory.make_Neighbour() factory.make_Neighbour() self.assertThat(MDNS.objects.count(), Equals(2)) self.assertThat(Neighbour.objects.count(), Equals(2)) Discovery.objects.clear(neighbours=True) self.assertThat(MDNS.objects.count(), Equals(2)) self.assertThat(Neighbour.objects.count(), Equals(0)) self.assertThat( maaslog, MockCalledOnceWith( Matches(DocTestMatches('Cleared all neighbour entries.'))))