# Path: uchroma/server/hardware.py
# class Hardware(BaseHardware):
#     """
#     Static hardware configuration data
# 
#     Loaded by Configuration from YAML.
#     """
# 
#     class Type(Enum):
#         HEADSET = 'Headset'
#         KEYBOARD = 'Keyboard'
#         KEYPAD = 'Keypad'
#         LAPTOP = 'Laptop'
#         MOUSE = 'Mouse'
#         MOUSEPAD = 'Mousepad'
# 
#     @property
#     def has_matrix(self) -> bool:
#         """
#         True if the device has an addressable key matrix
#         """
#         return self.dimensions is not None and self.dimensions.x > 1 and self.dimensions.y > 1
# 
# 
#     def has_quirk(self, *quirks) -> bool:
#         """
#         True if quirk is required for the device
# 
#         :param: quirks The quirks to check (varargs)
# 
#         :return: True if the quirk is required
#         """
#         if self.quirks is None:
#             return False
# 
#         for quirk in quirks:
#             if isinstance(self.quirks, (list, tuple)) and quirk in self.quirks:
#                 return True
#             if self.quirks == quirk:
#                 return True
# 
#         return False
# 
# 
#     @classmethod
#     def get_type(cls, hw_type) -> 'Hardware':
#         if hw_type is None:
#             return None
# 
#         config_path = os.path.join(os.path.dirname(__file__), 'data')
#         yaml_path = os.path.join(config_path, '%s.yaml' % hw_type.name.lower())
# 
#         config = cls.load_yaml(yaml_path)
#         assert config is not None
# 
#         return config
# 
# 
#     @classmethod
#     def _get_device(cls, product_id: int, hw_type) -> 'Hardware':
#         if product_id is None:
#             return None
# 
#         config = cls.get_type(hw_type)
# 
#         result = config.search('product_id', product_id)
#         if not result:
#             return None
# 
#         if isinstance(result, list) and len(result) == 1:
#             return result[0]
# 
#         return result
# 
# 
#     @classmethod
#     def get_device(cls, product_id: int, hw_type=None) -> 'Hardware':
#         if hw_type is not None:
#             return cls._get_device(product_id, hw_type)
# 
#         for hw in Hardware.Type:
#             device = cls._get_device(product_id, hw)
#             if device is not None:
#                 return device
# 
#         return None
# 
# 
#     def _yaml_header(self) -> str:
#         header = '#\n#  uChroma device configuration\n#\n'
#         if self.name is not None:
#             header += '#  Model: %s (%s)\n' % (self.name, self.type.value)
#         elif self.type is not None:
#             header += '#  Type: %s\n' % self.type.name.title()
#         header += '#  Updated on: %s\n' % datetime.now().isoformat(' ')
#         header += '#\n'
# 
#         return header
# 
# class KeyMapping(OrderedDict):
#     def __setitem__(self, key, value, **kwargs):
#         super().__setitem__(key, PointList(value), **kwargs)
# 
# class Point(_Point):
#     def __repr__(self):
#         return '(%s, %s)' % (self.y, self.x)
# 
# class PointList(FlowSequence):
#     def __new__(cls, args):
#         if isinstance(args, list):
#             if isinstance(args[0], int) and len(args) == 2:
#                 return Point(args[0], args[1])
#             if isinstance(args[0], list):
#                 return cls([cls(arg) for arg in args])
#         return super(PointList, cls).__new__(cls, args)


import os
from uchroma.server.hardware import Hardware, KeyMapping, Point, PointList



def test_config_loaded():
    assert Hardware.get_device(0x210).product_id == 0x0210

def test_recursive_attribute():

# Path: uchroma/server/hardware.py
# class Hardware(BaseHardware):
#     """
#     Static hardware configuration data
# 
#     Loaded by Configuration from YAML.
#     """
# 
#     class Type(Enum):
#         HEADSET = 'Headset'
#         KEYBOARD = 'Keyboard'
#         KEYPAD = 'Keypad'
#         LAPTOP = 'Laptop'
#         MOUSE = 'Mouse'
#         MOUSEPAD = 'Mousepad'
# 
#     @property
#     def has_matrix(self) -> bool:
#         """
#         True if the device has an addressable key matrix
#         """
#         return self.dimensions is not None and self.dimensions.x > 1 and self.dimensions.y > 1
# 
# 
#     def has_quirk(self, *quirks) -> bool:
#         """
#         True if quirk is required for the device
# 
#         :param: quirks The quirks to check (varargs)
# 
#         :return: True if the quirk is required
#         """
#         if self.quirks is None:
#             return False
# 
#         for quirk in quirks:
#             if isinstance(self.quirks, (list, tuple)) and quirk in self.quirks:
#                 return True
#             if self.quirks == quirk:
#                 return True
# 
#         return False
# 
# 
#     @classmethod
#     def get_type(cls, hw_type) -> 'Hardware':
#         if hw_type is None:
#             return None
# 
#         config_path = os.path.join(os.path.dirname(__file__), 'data')
#         yaml_path = os.path.join(config_path, '%s.yaml' % hw_type.name.lower())
# 
#         config = cls.load_yaml(yaml_path)
#         assert config is not None
# 
#         return config
# 
# 
#     @classmethod
#     def _get_device(cls, product_id: int, hw_type) -> 'Hardware':
#         if product_id is None:
#             return None
# 
#         config = cls.get_type(hw_type)
# 
#         result = config.search('product_id', product_id)
#         if not result:
#             return None
# 
#         if isinstance(result, list) and len(result) == 1:
#             return result[0]
# 
#         return result
# 
# 
#     @classmethod
#     def get_device(cls, product_id: int, hw_type=None) -> 'Hardware':
#         if hw_type is not None:
#             return cls._get_device(product_id, hw_type)
# 
#         for hw in Hardware.Type:
#             device = cls._get_device(product_id, hw)
#             if device is not None:
#                 return device
# 
#         return None
# 
# 
#     def _yaml_header(self) -> str:
#         header = '#\n#  uChroma device configuration\n#\n'
#         if self.name is not None:
#             header += '#  Model: %s (%s)\n' % (self.name, self.type.value)
#         elif self.type is not None:
#             header += '#  Type: %s\n' % self.type.name.title()
#         header += '#  Updated on: %s\n' % datetime.now().isoformat(' ')
#         header += '#\n'
# 
#         return header
# 
# class KeyMapping(OrderedDict):
#     def __setitem__(self, key, value, **kwargs):
#         super().__setitem__(key, PointList(value), **kwargs)
# 
# class Point(_Point):
#     def __repr__(self):
#         return '(%s, %s)' % (self.y, self.x)
# 
# class PointList(FlowSequence):
#     def __new__(cls, args):
#         if isinstance(args, list):
#             if isinstance(args[0], int) and len(args) == 2:
#                 return Point(args[0], args[1])
#             if isinstance(args[0], list):
#                 return cls([cls(arg) for arg in args])
#         return super(PointList, cls).__new__(cls, args)


# Path: tests/test_config.py
import os
from uchroma.server.hardware import Hardware, KeyMapping, Point, PointList




def test_config_loaded():
    assert Hardware.get_device(0x210).product_id == 0x0210

def test_recursive_attribute():

    assert Hardware.get_device(0x210).vendor_id == 0x1532