def test_phue_bridge_info_success(mocked_function): with open(asset_path('devices.json')) as f: mocked_function.return_value = json.load(f) assert hub_metadata.HubMetaData.phue_bridge_info('', '127.0.0.2') == { 'apiversion': '1.22.0', 'datastoreversion': '65', 'mac': '00:17:88:79:53:98', 'swversion': '1711151408' }
def settings(): return { 'testing': True, 'debug': False, 'bin_path': asset_path('bin'), 'wifi_networks_path': asset_path('wifi_networks.json'), 'wifi_setup_flag_path': asset_path('nuimo_setup_required'), 'wifi_adhoc_ssid': 'Setup Nuimo', 'crypto_settings_datafile': asset_path('testing.yml.aes'), 'crypto_settings_keyfile': asset_path('testing.key'), 'devices_path': asset_path('devices.json'), 'data_path': '/tmp', 'nuimo_mac_address_filepath': asset_path('nuimo_mac_address.txt'), 'nuimo_app_config_path': asset_path('nuimo_app.yaml'), 'config_ini_path': '/no/such/file.ini', 'joined_wifi_path': asset_path('joined_wifi.json'), 'senic_hub_data_path': asset_path(), 'hub_ip_address': '0.0.0.0' }
def test_read_from_json_file(): devices = hub_metadata.HubMetaData._read_from_file( asset_path('devices.json')) assert devices == [{ 'id': 'ph1', 'type': 'philips_hue', 'name': 'Philips Hue Bridge 1', 'ip': '127.0.0.1', 'authenticationRequired': True, 'authenticated': False, 'extra': {} }, { 'id': 'ph2', 'type': 'philips_hue', 'name': 'Philips Hue Bridge 2', 'ip': '127.0.0.2', 'authenticationRequired': True, 'authenticated': True, 'extra': { 'username': '******', 'lights': { '5': { 'name': ' Light 5' }, '7': { 'name': ' Light 7' }, '4': { 'name': ' Light 4' }, '8': { 'name': ' Light 8' }, '6': { 'name': ' Light 6' } }, 'bridge': { 'apiversion': '1.22.0', 'datastoreversion': '65', 'mac': '00:17:88:79:53:98', 'swversion': '1711151408' } } }, { 'id': 's1', 'type': 'sonos', 'name': 'Sonos Player S1', 'ip': '127.0.0.1', 'authenticationRequired': False, 'authenticated': True, 'extra': {} }]
def test_wifi_success(mocked_function): with open(asset_path('system-connections')) as f: mocked_function.return_value = f.readlines() assert hub_metadata.HubMetaData.wifi() == 'test'
def test_os_version_fail(mocked_function): with open(asset_path('empty')) as f: mocked_function.return_value = f.readlines() assert hub_metadata.HubMetaData.os_version() == ''
def test_os_version_success(mocked_function): with open(asset_path('os-release')) as f: mocked_function.return_value = f.readlines() assert hub_metadata.HubMetaData.os_version() == '0.1.8'
def test_phue_bridge_info_wrong_ip(mocked_function): with open(asset_path('devices.json')) as f: mocked_function.return_value = json.load(f) assert hub_metadata.HubMetaData.phue_bridge_info('', '127.0.0.5') == {}
def test_hardware_identifier_fail(mocked_function): with open(asset_path('empty')) as f: mocked_function.return_value = f.readlines() assert hub_metadata.HubMetaData.hardware_identifier() == ''
def test_hardware_identifier_success(mocked_function): with open(asset_path('cpuinfo')) as f: mocked_function.return_value = f.readlines() assert hub_metadata.HubMetaData.hardware_identifier() == '9e32509e'