def test_source_cidrs_out_of_range(self): request = mock.Mock(client_addr='99.0.0.1') with self.assertRaises(validators.ValidationError) as e: validators.source_cidrs( request=request, cidrs=['127/8', '10/8']) self.assertEqual("No network matched the request source '99.0.0.1'", str(e.exception))
def test_source_cidrs_bad_cidr(self): request = mock.Mock(client_addr='127.0.0.1') with self.assertRaises(validators.ValidationError) as e: validators.source_cidrs( request=request, cidrs=['bad']) self.assertEqual("Cidr 'bad' does not describe a valid network", str(e.exception))
def test_source_cidrs_good(self): request = mock.Mock(client_addr='127.0.0.1') self.assertEqual( None, validators.source_cidrs( request=request, cidrs=['127/8', '10/8'] ) )