# Path: tuskar/db/sqlalchemy/api.py
# CONF = cfg.CONF
# LOG = log.getLogger(__name__)
# def get_backend():
# def model_query(model, *args, **kwargs):
#     def __init__(self):
#     def get_heat_data(self):
#     def get_racks(self, columns):
#     def get_rack(self, rack_id):
#     def get_racks_by_resource_class(self, resource_class_id):
#     def get_resource_classes(self, columns):
#     def get_resource_class(self, resource_class_id):
#     def create_resource_class(self, new_resource_class):
#     def update_resource_class(self, resource_class_id, new_resource_class):
#     def create_resource_class_flavor(self, resource_class_id, new_flavor):
#     def update_flavor_nova_uuid(self, flavor_id, nova_uuid):
#     def update_resource_class_flavor(self, resource_class_id, flavor_id, new_flavor):
#     def update_rack_state(self, rack, heat_stack_status):
#     def update_rack(self, rack_id, new_rack):
#     def create_rack(self, new_rack):
#     def delete_rack(self, rack_id):
#     def delete_resource_class(self, resource_class_id):
#     def get_flavors(self, resource_class_id):
#     def get_flavor(self, flavor_id):
#     def create_flavor(self, new_flavor):
#     def delete_flavor(self, flavor_id):
#     def delete_capacities(self, resource, session):
# class Connection(api.Connection):
# 
# Path: tuskar/tests/api/api.py
# class FunctionalTest(base.TestCase):
#     PATH_PREFIX = '/v1'
#     SOURCE_DATA = {'test_source': {'somekey': '666'}}
#     def setUp(self):
#     def _make_app(self, enable_acl=False):
#     def tearDown(self):
#     def put_json(self, path, params, expect_errors=False, headers=None,
#                  extra_environ=None, status=None):
#     def delete_json(self, path, expect_errors=False, headers=None,
#                     extra_environ=None, status=None):
#     def post_json(self, path, params, expect_errors=False, headers=None,
#                   method="post", extra_environ=None, status=None):
#     def delete(self, path, expect_errors=False, headers=None,
#                extra_environ=None, status=None):
#     def get_json(self, path, expect_errors=False, headers=None,
#                  extra_environ=None, q=[], **params):
# 
# Path: tuskar/api/controllers/v1/types/rack.py
# class Rack(Base):
#     """A representation of Rack in HTTP body."""
# 
#     id = int
#     name = wtypes.text
#     slots = int
#     subnet = wtypes.text
#     location = wtypes.text
#     state = wtypes.text
#     chassis = Chassis
#     capacities = [Capacity]
#     nodes = [Node]
#     links = [Link]
#     resource_class = Relation
# 
#     @classmethod
#     def convert_with_links(self, rack, links):
# 
#         kwargs = rack.as_dict() # returns a new dict, overwriting keys is safe
# 
#         if rack.chassis_id:
#             kwargs['chassis'] = Chassis(id=rack.chassis_id,
#                                         links=[Link.build_ironic_link('chassis',
#                                                             rack.chassis_id)])
#         else:
#             kwargs['chassis'] = Chassis()
# 
#         if rack.resource_class_id:
#             l = [Link.build('self', pecan.request.host_url, 'resource_classes',
#                             rack.resource_class_id)]
#             kwargs['resource_class'] = Relation(id=rack.resource_class_id,
#                                                 links=l)
# 
#         kwargs['capacities'] = [Capacity(name=c.name, value=c.value,
#                                                unit=c.unit)
#                                                for c in rack.capacities]
# 
#         kwargs['nodes'] = [Node(id=n.node_id,
#                                       links=[Link.build_ironic_link('node', n.node_id)])
#                                  for n in rack.nodes]
# 
#         return Rack(links=links, **kwargs)
# 
#     @classmethod
#     def convert(self, rack, base_url, minimal=False):
#         links = [Link.build('self', pecan.request.host_url, 'rack',
#                             rack.id)]
#         if minimal:
#             return Rack(links=links, id=str(rack.id))
# 
# Path: tuskar/api/controllers/v1/types/resource_class.py
# class ResourceClass(Base):
#     """A representation of Resource Class in HTTP body."""
# 
#     id = int
#     name = wtypes.text
#     service_type = wtypes.text
#     racks = [Relation]
#     flavors = [Flavor]
#     links = [Link]
# 
#     @classmethod
#     def convert(self, resource_class, base_url, minimal=False):
#         links = [Link.build('self', pecan.request.host_url, 'resource_classes',
#                             resource_class.id)]
#         if minimal:
#             return ResourceClass(links=links, id=str(resource_class.id))
#         else:
#             racks = []
#             if resource_class.racks:
#                 for r in resource_class.racks:
#                     l = [Link.build('self', pecan.request.host_url,
#                                     'racks', r.id)]
#                     rack = Relation(id=r.id, links=l)
#                     racks.append(rack)
# 
#             flavors = []
#             if resource_class.flavors:
#                 for flav in resource_class.flavors:
# 
#                     flavor = Flavor.add_capacities(resource_class.id, flav)
#                     flavors.append(flavor)
#             return ResourceClass(links=links, racks=racks, flavors=flavors,
#                                  **(resource_class.as_dict()))


from tuskar.db.sqlalchemy import api as dbapi
from tuskar.tests.api import api
from tuskar.api.controllers.v1.types import ResourceClass, Rack

class TestResourceClasses(api.FunctionalTest):

    db = dbapi.get_backend()

    def setUp(self):
        super(TestResourceClasses, self).setUp()

# Path: tuskar/db/sqlalchemy/api.py
# CONF = cfg.CONF
# LOG = log.getLogger(__name__)
# def get_backend():
# def model_query(model, *args, **kwargs):
#     def __init__(self):
#     def get_heat_data(self):
#     def get_racks(self, columns):
#     def get_rack(self, rack_id):
#     def get_racks_by_resource_class(self, resource_class_id):
#     def get_resource_classes(self, columns):
#     def get_resource_class(self, resource_class_id):
#     def create_resource_class(self, new_resource_class):
#     def update_resource_class(self, resource_class_id, new_resource_class):
#     def create_resource_class_flavor(self, resource_class_id, new_flavor):
#     def update_flavor_nova_uuid(self, flavor_id, nova_uuid):
#     def update_resource_class_flavor(self, resource_class_id, flavor_id, new_flavor):
#     def update_rack_state(self, rack, heat_stack_status):
#     def update_rack(self, rack_id, new_rack):
#     def create_rack(self, new_rack):
#     def delete_rack(self, rack_id):
#     def delete_resource_class(self, resource_class_id):
#     def get_flavors(self, resource_class_id):
#     def get_flavor(self, flavor_id):
#     def create_flavor(self, new_flavor):
#     def delete_flavor(self, flavor_id):
#     def delete_capacities(self, resource, session):
# class Connection(api.Connection):
# 
# Path: tuskar/tests/api/api.py
# class FunctionalTest(base.TestCase):
#     PATH_PREFIX = '/v1'
#     SOURCE_DATA = {'test_source': {'somekey': '666'}}
#     def setUp(self):
#     def _make_app(self, enable_acl=False):
#     def tearDown(self):
#     def put_json(self, path, params, expect_errors=False, headers=None,
#                  extra_environ=None, status=None):
#     def delete_json(self, path, expect_errors=False, headers=None,
#                     extra_environ=None, status=None):
#     def post_json(self, path, params, expect_errors=False, headers=None,
#                   method="post", extra_environ=None, status=None):
#     def delete(self, path, expect_errors=False, headers=None,
#                extra_environ=None, status=None):
#     def get_json(self, path, expect_errors=False, headers=None,
#                  extra_environ=None, q=[], **params):
# 
# Path: tuskar/api/controllers/v1/types/rack.py
# class Rack(Base):
#     """A representation of Rack in HTTP body."""
# 
#     id = int
#     name = wtypes.text
#     slots = int
#     subnet = wtypes.text
#     location = wtypes.text
#     state = wtypes.text
#     chassis = Chassis
#     capacities = [Capacity]
#     nodes = [Node]
#     links = [Link]
#     resource_class = Relation
# 
#     @classmethod
#     def convert_with_links(self, rack, links):
# 
#         kwargs = rack.as_dict() # returns a new dict, overwriting keys is safe
# 
#         if rack.chassis_id:
#             kwargs['chassis'] = Chassis(id=rack.chassis_id,
#                                         links=[Link.build_ironic_link('chassis',
#                                                             rack.chassis_id)])
#         else:
#             kwargs['chassis'] = Chassis()
# 
#         if rack.resource_class_id:
#             l = [Link.build('self', pecan.request.host_url, 'resource_classes',
#                             rack.resource_class_id)]
#             kwargs['resource_class'] = Relation(id=rack.resource_class_id,
#                                                 links=l)
# 
#         kwargs['capacities'] = [Capacity(name=c.name, value=c.value,
#                                                unit=c.unit)
#                                                for c in rack.capacities]
# 
#         kwargs['nodes'] = [Node(id=n.node_id,
#                                       links=[Link.build_ironic_link('node', n.node_id)])
#                                  for n in rack.nodes]
# 
#         return Rack(links=links, **kwargs)
# 
#     @classmethod
#     def convert(self, rack, base_url, minimal=False):
#         links = [Link.build('self', pecan.request.host_url, 'rack',
#                             rack.id)]
#         if minimal:
#             return Rack(links=links, id=str(rack.id))
# 
# Path: tuskar/api/controllers/v1/types/resource_class.py
# class ResourceClass(Base):
#     """A representation of Resource Class in HTTP body."""
# 
#     id = int
#     name = wtypes.text
#     service_type = wtypes.text
#     racks = [Relation]
#     flavors = [Flavor]
#     links = [Link]
# 
#     @classmethod
#     def convert(self, resource_class, base_url, minimal=False):
#         links = [Link.build('self', pecan.request.host_url, 'resource_classes',
#                             resource_class.id)]
#         if minimal:
#             return ResourceClass(links=links, id=str(resource_class.id))
#         else:
#             racks = []
#             if resource_class.racks:
#                 for r in resource_class.racks:
#                     l = [Link.build('self', pecan.request.host_url,
#                                     'racks', r.id)]
#                     rack = Relation(id=r.id, links=l)
#                     racks.append(rack)
# 
#             flavors = []
#             if resource_class.flavors:
#                 for flav in resource_class.flavors:
# 
#                     flavor = Flavor.add_capacities(resource_class.id, flav)
#                     flavors.append(flavor)
#             return ResourceClass(links=links, racks=racks, flavors=flavors,
#                                  **(resource_class.as_dict()))


# Path: tuskar/tests/api/controllers/v1/test_resource_class.py
from tuskar.db.sqlalchemy import api as dbapi
from tuskar.tests.api import api
from tuskar.api.controllers.v1.types import ResourceClass, Rack


class TestResourceClasses(api.FunctionalTest):

    db = dbapi.get_backend()

    def setUp(self):
        super(TestResourceClasses, self).setUp()

        self.rc = self.db.create_resource_class(ResourceClass(