def test__scan_as_admin_logs_the_fact_that_a_scan_happened(self):
user = factory.make_admin()
handler = SubnetHandler(user, {})
subnet = factory.make_Subnet(version=4)
rack = factory.make_RackController()
factory.make_Interface(node=rack, subnet=subnet)
logger = self.useFixture(FakeLogger())
cidr = subnet.get_ipnetwork()
handler.scan({
"id": subnet.id,
})
# Use MatchesRegex here rather than DocTestMatches because usernames
# can contain characters that confuse DocTestMatches (e.g. periods).
self.assertThat(logger.output, MatchesRegex(
"User '%s' initiated a neighbour discovery scan against subnet: %s"
% (re.escape(user.username), re.escape(str(cidr)))))
评论列表
文章目录