def test_list_values(self): ''' Test - List the values under a subkey. ''' subkey = r'Software\Microsoft\Windows NT\CurrentVersion' test_list = win_mod_reg.list_values('HKEY_LOCAL_MACHINE', subkey) test = len(test_list) > 5 # There should be a lot more than 5 items self.assertTrue(test)
def test_list_values_fail(self): ''' Test - List the values under a subkey which does not exist. ''' subkey = 'ThisIsJunkItDoesNotExistIhope' test_list = win_mod_reg.list_values('HKEY_LOCAL_MACHINE', subkey) # returns a tuple with first item false, and second item a reason test = isinstance(test_list, tuple) and (not test_list[0]) self.assertTrue(test)
def test_list_values_existing(self): """ Test the list_values function using a well known registry key """ values = reg.list_values( hive="HKLM", key="SOFTWARE\\Microsoft\\Windows\\CurrentVersion") keys = [] for value in values: keys.append(value["vname"]) self.assertIn("ProgramFilesDir", keys)
def test_list_values_existing(self): ''' Test the list_values function using a well known registry key ''' values = reg.list_values( hive='HKLM', key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion') keys = [] for value in values: keys.append(value['vname']) self.assertIn('ProgramFilesDir', keys)
def test_list_values_non_existing(self): """ Test the list_values function using a non existing registry key """ expected = (False, "Cannot find key: HKLM\\{}".format(FAKE_KEY)) self.assertEqual(reg.list_values(hive="HKLM", key=FAKE_KEY), expected)
def test_list_values_non_existing(self): ''' Test the list_values function using a non existing registry key ''' expected = (False, 'Cannot find key: HKLM\\{0}'.format(FAKE_KEY)) self.assertEqual(reg.list_values(hive='HKLM', key=FAKE_KEY), expected)