def test_list_keys(self): ''' Test - Read list the keys under a subkey ''' subkey = 'Software\\Microsoft\\Windows NT\\CurrentVersion' test_list = win_mod_reg.list_keys('HKEY_LOCAL_MACHINE', subkey) test = len(test_list) > 5 # Their should be a lot more than 5 items self.assertTrue(test)
def test_list_keys_fail(self): ''' Test - Read list the keys under a subkey which does not exist. ''' subkey = 'ThisIsJunkItDoesNotExistIhope' test_list = win_mod_reg.list_keys('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_keys_non_existing(self): """ Test the list_keys function using a non existing registry key """ expected = (False, "Cannot find key: HKLM\\{}".format(FAKE_KEY)) self.assertEqual(reg.list_keys(hive="HKLM", key=FAKE_KEY), expected)
def test_list_keys_existing(self): """ Test the list_keys function using a well known registry key """ self.assertIn("Microsoft", reg.list_keys(hive="HKLM", key="SOFTWARE"))
def test_list_keys_non_existing(self): ''' Test the list_keys function using a non existing registry key ''' expected = (False, 'Cannot find key: HKLM\\{0}'.format(FAKE_KEY)) self.assertEqual(reg.list_keys(hive='HKLM', key=FAKE_KEY), expected)
def test_list_keys_existing(self): ''' Test the list_keys function using a well known registry key ''' self.assertIn('Microsoft', reg.list_keys(hive='HKLM', key='SOFTWARE'))