Example #1
0
    def test_validate(self):
        validator = validators.RequiredCinderServicesValidator(
            "cinder_service")

        fake_service = mock.Mock(binary="cinder_service", state="up")
        clients = self.credentials["openstack"]["admin"].clients()
        clients.cinder().services.list.return_value = [fake_service]
        result = validator.validate(self.config, self.credentials, None, None)
        self.assertIsNone(result)

        fake_service.state = "down"
        result = validator.validate(self.config, self.credentials, None, None)
        self.assertTrue(result)
        self.assertEqual("cinder_service service is not available", result.msg)
Example #2
0
    def test_validate(self):
        validator = validators.RequiredCinderServicesValidator(
            "cinder_service")

        fake_service = mock.Mock(binary="cinder_service", state="up")
        clients = self.context["admin"]["credential"].clients()
        clients.cinder().services.list.return_value = [fake_service]
        result = validator.validate(self.context, self.config, None, None)
        self.assertIsNone(result)

        fake_service.state = "down"
        e = self.assertRaises(validators.validation.ValidationError,
                              validator.validate, self.context, self.config,
                              None, None)
        self.assertEqual("cinder_service service is not available", e.message)