def test_create_with_invalid_unicode_name(self, mock_openstack_client_class, mock_driver, mock_cert_manager, mock_trust_manager, mock_cluster_create): error_message = six.u("""Invalid stack name 测试集群-zoyh253geukk must contain only alphanumeric or "_-." characters, must start with alpha""") mock_dr = mock.MagicMock() mock_driver.return_value = mock_dr mock_dr.create_cluster.side_effect = exc.HTTPBadRequest(error_message) self._test_create_failed(mock_openstack_client_class, mock_cert_manager, mock_trust_manager, mock_cluster_create, exception.InvalidParameterValue) notifications = fake_notifier.NOTIFICATIONS self.assertEqual(2, len(notifications)) self.assertEqual('magnum.cluster.create', notifications[0].event_type) self.assertEqual(taxonomy.OUTCOME_PENDING, notifications[0].payload['outcome']) self.assertEqual('magnum.cluster.create', notifications[1].event_type) self.assertEqual(taxonomy.OUTCOME_FAILURE, notifications[1].payload['outcome'])
def test_nodegroup_update_failed_bad_request(self, mock_get_driver): mock_driver = mock.MagicMock() mock_get_driver.return_value = mock_driver side_effect = exc.HTTPBadRequest("Bad request") mock_driver.update_nodegroup.side_effect = side_effect self.assertRaises(exception.InvalidParameterValue, self.handler.nodegroup_update, self.context, self.cluster, self.nodegroup) mock_driver.update_nodegroup.assert_called_once_with( self.context, self.cluster, self.nodegroup) self.assertEqual(fields.ClusterStatus.UPDATE_FAILED, self.cluster.status) self.assertEqual(fields.ClusterStatus.UPDATE_FAILED, self.nodegroup.status) self.assertEqual("ERROR: Bad request", self.nodegroup.status_reason)
def test_create_with_invalid_unicode_name(self, mock_openstack_client_class, mock_uuid, mock_create_stack, mock_cert_manager, mock_trust_manager): test_uuid = uuid.uuid4() mock_uuid.uuid4.return_value = test_uuid error_message = six.u("""Invalid stack name 测试集群-zoyh253geukk must contain only alphanumeric or "_-." characters, must start with alpha""") mock_create_stack.side_effect = exc.HTTPBadRequest(error_message) self._test_create_failed(mock_openstack_client_class, mock_cert_manager, mock_trust_manager, exception.InvalidParameterValue)
def test_create_with_invalid_unicode_name(self, mock_uuid, mock_create_stack, mock_cert_manager): timeout = 15 test_uuid = uuid.uuid4() mock_uuid.uuid4.return_value = test_uuid error_message = six.u("""Invalid stack name 测试集群-zoyh253geukk must contain only alphanumeric or "_-." characters, must start with alpha""") mock_create_stack.side_effect = exc.HTTPBadRequest(error_message) self.assertRaises(exception.InvalidParameterValue, self.handler.bay_create, self.context, self.bay, timeout) mock_cert_manager.generate_certificates_to_bay.assert_called_once_with( self.bay)