# Path: resources/lib/utils.py
# def get_user_agent():
#     """
#     Determines the user agent string for the current platform.
#     Needed to retrieve a valid ESN (except for Android, where the ESN can
#     be generated locally)
# 
#     :returns: str -- User agent string
#     """
#     chrome_version = 'Chrome/59.0.3071.115'
#     base = 'Mozilla/5.0 '
#     base += '%PL% '
#     base += 'AppleWebKit/537.36 (KHTML, like Gecko) '
#     base += '%CH_VER% Safari/537.36'.replace('%CH_VER%', chrome_version)
#     system = platform.system()
#     # Mac OSX
#     if system == 'Darwin':
#         return base.replace('%PL%', '(Macintosh; Intel Mac OS X 10_10_1)')
#     # Windows
#     if system == 'Windows':
#         return base.replace('%PL%', '(Windows NT 6.1; WOW64)')
#     # ARM based Linux
#     if platform.machine().startswith('arm'):
#         return base.replace('%PL%', '(X11; CrOS armv7l 7647.78.0)')
#     # x86 Linux
#     return base.replace('%PL%', '(X11; Linux x86_64)')
# 
# def noop(**kwargs):
#     """Takes everything, does nothing, classic no operation function"""
#     return kwargs
# 
# def uniq_id(delay=1):
#     """
#     Returns a unique id based on the devices MAC address
# 
#     :param delay: Retry delay in sec
#     :type delay: int
#     :returns:  string -- Unique secret
#     """
#     mac_addr = __get_mac_address(delay=delay)
#     if ':' in mac_addr and delay == 2:
#         return hashlib.sha256(str(mac_addr).encode()).digest()
#     else:
#         return hashlib.sha256('UnsafeStaticSecret'.encode()).digest()
# 
# def get_class_methods(class_item=None):
#     """
#     Returns the class methods of agiven class object
# 
#     :param class_item: Class item to introspect
#     :type class_item: object
#     :returns: list -- Class methods
#     """
#     _type = FunctionType
#     return [x for x, y in class_item.__dict__.items() if isinstance(y, _type)]
# 
# def __get_mac_address(delay=1):
#     """
#     Returns the users mac address
# 
#     :param delay: retry delay in sec
#     :type delay: int
#     :returns:  string -- Devices MAC address
#     """
#     mac_addr = xbmc.getInfoLabel('Network.MacAddress')
#     # hack response busy
#     i = 0
#     while ':' not in mac_addr and i < 3:
#         i += 1
#         time.sleep(delay)
#         mac_addr = xbmc.getInfoLabel('Network.MacAddress')
#     return mac_addr


import unittest
import mock
from resources.lib.utils import get_user_agent, noop, uniq_id, get_class_methods, __get_mac_address as gma
from mocks.MinimalClassMocks import MockClass
from mocks.LoggerMocks import TestLoggerWithArgs, TestLoggerWithCredentialArgs, TestLoggerWithNoArgs
            member='armv')

    @mock.patch('xbmcaddon.Addon')
    def test_uniq_id(self, mock_xbmcaddon):
        """ADD ME"""
        self.assertEquals(
            first=uniq_id(delay=1),
            second='=\x05\xc1\xf7\x0b\xb5&\xd0\xa2\xd1]\xce\xf3\xee\x92\x8a\xb5\xc7\x985\x8a{\xf5A6TD\xf3/\x93\x84W')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address_delay(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00:80:41:ae:fd:7e'
        self.assertEqual(
            first=uniq_id(delay=2),
            second='\xf7K\x87\xb3\xc4\xd2\xd4\xea7\x91\x99( C\xb2\x8e\xa7\x8d}L\xdbP\x93\xfaM&4\x8a\xb6\xda\xcfG')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00:80:41:ae:fd:7e'
        self.assertEqual(
            first=gma(),
            second='00:80:41:ae:fd:7e')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address_malformed(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00-80-41-ae-fd-7e'
        self.assertEqual(

# Path: resources/lib/utils.py
# def get_user_agent():
#     """
#     Determines the user agent string for the current platform.
#     Needed to retrieve a valid ESN (except for Android, where the ESN can
#     be generated locally)
# 
#     :returns: str -- User agent string
#     """
#     chrome_version = 'Chrome/59.0.3071.115'
#     base = 'Mozilla/5.0 '
#     base += '%PL% '
#     base += 'AppleWebKit/537.36 (KHTML, like Gecko) '
#     base += '%CH_VER% Safari/537.36'.replace('%CH_VER%', chrome_version)
#     system = platform.system()
#     # Mac OSX
#     if system == 'Darwin':
#         return base.replace('%PL%', '(Macintosh; Intel Mac OS X 10_10_1)')
#     # Windows
#     if system == 'Windows':
#         return base.replace('%PL%', '(Windows NT 6.1; WOW64)')
#     # ARM based Linux
#     if platform.machine().startswith('arm'):
#         return base.replace('%PL%', '(X11; CrOS armv7l 7647.78.0)')
#     # x86 Linux
#     return base.replace('%PL%', '(X11; Linux x86_64)')
# 
# def noop(**kwargs):
#     """Takes everything, does nothing, classic no operation function"""
#     return kwargs
# 
# def uniq_id(delay=1):
#     """
#     Returns a unique id based on the devices MAC address
# 
#     :param delay: Retry delay in sec
#     :type delay: int
#     :returns:  string -- Unique secret
#     """
#     mac_addr = __get_mac_address(delay=delay)
#     if ':' in mac_addr and delay == 2:
#         return hashlib.sha256(str(mac_addr).encode()).digest()
#     else:
#         return hashlib.sha256('UnsafeStaticSecret'.encode()).digest()
# 
# def get_class_methods(class_item=None):
#     """
#     Returns the class methods of agiven class object
# 
#     :param class_item: Class item to introspect
#     :type class_item: object
#     :returns: list -- Class methods
#     """
#     _type = FunctionType
#     return [x for x, y in class_item.__dict__.items() if isinstance(y, _type)]
# 
# def __get_mac_address(delay=1):
#     """
#     Returns the users mac address
# 
#     :param delay: retry delay in sec
#     :type delay: int
#     :returns:  string -- Devices MAC address
#     """
#     mac_addr = xbmc.getInfoLabel('Network.MacAddress')
#     # hack response busy
#     i = 0
#     while ':' not in mac_addr and i < 3:
#         i += 1
#         time.sleep(delay)
#         mac_addr = xbmc.getInfoLabel('Network.MacAddress')
#     return mac_addr


# Path: resources/test/test_Utils.py
import unittest
import mock
from resources.lib.utils import get_user_agent, noop, uniq_id, get_class_methods, __get_mac_address as gma
from mocks.MinimalClassMocks import MockClass
from mocks.LoggerMocks import TestLoggerWithArgs, TestLoggerWithCredentialArgs, TestLoggerWithNoArgs

            member='armv')

    @mock.patch('xbmcaddon.Addon')
    def test_uniq_id(self, mock_xbmcaddon):
        """ADD ME"""
        self.assertEquals(
            first=uniq_id(delay=1),
            second='=\x05\xc1\xf7\x0b\xb5&\xd0\xa2\xd1]\xce\xf3\xee\x92\x8a\xb5\xc7\x985\x8a{\xf5A6TD\xf3/\x93\x84W')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address_delay(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00:80:41:ae:fd:7e'
        self.assertEqual(
            first=uniq_id(delay=2),
            second='\xf7K\x87\xb3\xc4\xd2\xd4\xea7\x91\x99( C\xb2\x8e\xa7\x8d}L\xdbP\x93\xfaM&4\x8a\xb6\xda\xcfG')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00:80:41:ae:fd:7e'
        self.assertEqual(
            first=gma(),
            second='00:80:41:ae:fd:7e')

    @mock.patch('xbmc.getInfoLabel')
    def test_get_mac_address_malformed(self, mock_getInfoLabel):
        """ADD ME"""
        mock_getInfoLabel.return_value = '00-80-41-ae-fd-7e'
        self.assertEqual(

            first=gma(),