# Path: magnum_ui/api/rest/magnum.py
# LOG = logging.getLogger(__name__)
# def change_to_id(obj):
#     def get(self, request):
#     def get(self, request):
#     def get(self, request, template_id):
#     def patch(self, request, template_id):
#     def get(self, request):
#     def delete(self, request):
#     def post(self, request):
#     def get(self, request, cluster_id):
#     def patch(self, request, cluster_id):
#     def get(self, request, cluster_id):
#     def post(self, request, cluster_id):
#     def post(self, request, cluster_id):
#     def get(self, request):
#     def delete(self, request):
#     def post(self, request):
#     def get(self, request, cluster_id):
#     def delete(self, request, cluster_id):
#     def post(self, request):
#     def get(self, request):
#     def get(self, request, project_id, resource):
#     def patch(self, request, project_id, resource):
#     def delete(self, request, project_id, resource):
#     def get(self, request):
#     def post(self, request):
#     def get(self, request):
# class IngressControllers(generic.View):
# class Addons(generic.View):
# class ClusterTemplate(generic.View):
# class ClusterTemplates(generic.View):
# class Cluster(generic.View):
# class ClusterResize(generic.View):
# class ClusterUpgrade(generic.View):
# class Clusters(generic.View):
# class Certificate(generic.View):
# class Certificates(generic.View):
# class Stats(generic.View):
# class Quota(generic.View):
# class Quotas(generic.View):
# class Networks(generic.View):
# 
# Path: magnum_ui/test/test_data.py
# def data(TEST):


from unittest import mock
from oslo_serialization import jsonutils
from magnum_ui.api.rest import magnum
from magnum_ui.test import test_data
from openstack_dashboard.test import helpers as test
from openstack_dashboard.test.test_data import utils

    @mock.patch.object(magnum, 'magnum')
    def test_cluster_delete(self, client):
        test_cluster = TEST.clusters.first()
        request = self.mock_rest_request(
            body='{"cluster_id":' + str(test_cluster['uuid']) + '}')
        response = magnum.Clusters().delete(request)

        self.assertStatusCode(response, 204)
        client.cluster_delete.assert_called_once_with(
            request,
            u'cluster_id')

    # Certificates
    @mock.patch.object(magnum, 'magnum')
    def test_certificate_create(self, client):
        test_certificates = mock_resource(TEST.certificates.list())
        test_certificate = test_certificates[0]
        test_body = jsonutils.dumps(test_certificate.to_dict())
        request = self.mock_rest_request(body=test_body)

        test_res_list = mock_resource(TEST.certificate_res_list.list())
        test_res = test_res_list[0]
        client.certificate_create.return_value = test_res

        response = magnum.Certificates().post(request)
        res_body = jsonutils.loads(response.content.decode('utf-8'))

        self.assertStatusCode(response, 201)
        self.assertEqual(res_body['pem'], test_res.to_dict()['pem'])

# Path: magnum_ui/api/rest/magnum.py
# LOG = logging.getLogger(__name__)
# def change_to_id(obj):
#     def get(self, request):
#     def get(self, request):
#     def get(self, request, template_id):
#     def patch(self, request, template_id):
#     def get(self, request):
#     def delete(self, request):
#     def post(self, request):
#     def get(self, request, cluster_id):
#     def patch(self, request, cluster_id):
#     def get(self, request, cluster_id):
#     def post(self, request, cluster_id):
#     def post(self, request, cluster_id):
#     def get(self, request):
#     def delete(self, request):
#     def post(self, request):
#     def get(self, request, cluster_id):
#     def delete(self, request, cluster_id):
#     def post(self, request):
#     def get(self, request):
#     def get(self, request, project_id, resource):
#     def patch(self, request, project_id, resource):
#     def delete(self, request, project_id, resource):
#     def get(self, request):
#     def post(self, request):
#     def get(self, request):
# class IngressControllers(generic.View):
# class Addons(generic.View):
# class ClusterTemplate(generic.View):
# class ClusterTemplates(generic.View):
# class Cluster(generic.View):
# class ClusterResize(generic.View):
# class ClusterUpgrade(generic.View):
# class Clusters(generic.View):
# class Certificate(generic.View):
# class Certificates(generic.View):
# class Stats(generic.View):
# class Quota(generic.View):
# class Quotas(generic.View):
# class Networks(generic.View):
# 
# Path: magnum_ui/test/test_data.py
# def data(TEST):


# Path: magnum_ui/test/api_tests/test_rest_api.py
from unittest import mock
from oslo_serialization import jsonutils
from magnum_ui.api.rest import magnum
from magnum_ui.test import test_data
from openstack_dashboard.test import helpers as test
from openstack_dashboard.test.test_data import utils


    @mock.patch.object(magnum, 'magnum')
    def test_cluster_delete(self, client):
        test_cluster = TEST.clusters.first()
        request = self.mock_rest_request(
            body='{"cluster_id":' + str(test_cluster['uuid']) + '}')
        response = magnum.Clusters().delete(request)

        self.assertStatusCode(response, 204)
        client.cluster_delete.assert_called_once_with(
            request,
            u'cluster_id')

    # Certificates
    @mock.patch.object(magnum, 'magnum')
    def test_certificate_create(self, client):
        test_certificates = mock_resource(TEST.certificates.list())
        test_certificate = test_certificates[0]
        test_body = jsonutils.dumps(test_certificate.to_dict())
        request = self.mock_rest_request(body=test_body)

        test_res_list = mock_resource(TEST.certificate_res_list.list())
        test_res = test_res_list[0]
        client.certificate_create.return_value = test_res

        response = magnum.Certificates().post(request)
        res_body = jsonutils.loads(response.content.decode('utf-8'))

        self.assertStatusCode(response, 201)
        self.assertEqual(res_body['pem'], test_res.to_dict()['pem'])

        client.certificate_create.assert_called_once_with(