Example #1
0
  def testMultiDel(self, rv, build_info):
    # Mock delete registry keys
    args = [ROOT, PATH, NAME, False]
    rd = registry.RegDel(args, build_info)
    rd.Run()
    rv.assert_called_with(NAME, ROOT, PATH, False)

    # Missing arguments
    args = [ROOT, PATH]
    rd = registry.RegDel(args, build_info)
    self.assertRaises(registry.ActionError, rd.Run)

    # Multiple missing arguments
    args = [[ROOT, PATH], [ROOT]]
    rd = registry.MultiRegDel(args, build_info)
    self.assertRaises(registry.ActionError, rd.Run)
Example #2
0
  def testDelValidation(self):
    # List not passed
    r = registry.RegDel(NAME, None)
    self.assertRaises(registry.ValidationError, r.Validate)

    # Too many args
    r = registry.RegDel([ROOT, PATH, NAME, VALUE], None)
    self.assertRaises(registry.ValidationError, r.Validate)

    # Not enough args
    r = registry.RegDel([PATH, NAME], None)
    self.assertRaises(registry.ValidationError, r.Validate)

    # Too many keys
    r = registry.RegDel([[ROOT, PATH, NAME], [ROOT, PATH, NAME]], None)
    self.assertRaises(registry.ValidationError, r.Validate)

    # Valid calls
    r = registry.RegDel([ROOT, PATH, NAME], None)
    r.Validate()
Example #3
0
    def testDelValidation(self):
        # List not passed
        r = registry.RegDel('String', None)
        self.assertRaises(registry.ValidationError, r.Validate)

        # Too many args
        r = registry.RegDel(['HKLM', 'SOFTWARE/fake', 'foo', 'bar'], None)
        self.assertRaises(registry.ValidationError, r.Validate)

        # Not enough args
        r = registry.RegDel(['SOFTWARE/fake', 'foo'], None)
        self.assertRaises(registry.ValidationError, r.Validate)

        # Too many keys
        r = registry.RegDel([['HKLM', 'SOFTWARE/fake', 'foo'],
                             ['HKLM', 'SOFTWARE/boo', 'fake']], None)
        self.assertRaises(registry.ValidationError, r.Validate)

        # Valid calls
        r = registry.RegDel(['HKLM', 'SOFTWARE\fake', 'foo'], None)
        r.Validate()
Example #4
0
    def testMultiDel(self, winreg, build_info):
        # Mock delete registry keys
        kpath = (r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
                 r'\SoftwareProtectionPlatform')
        args = ['HKLM', kpath, 'KeyManagementServiceName', False]
        rkv = winreg.return_value.RemoveKeyValue
        rd = registry.RegDel(args, build_info)
        rd.Run()
        rkv.assert_called_with(key_path=kpath,
                               key_name='KeyManagementServiceName',
                               use_64bit=False)

        # Missing arguments
        args = ['HKLM', kpath]
        rd = registry.RegDel(args, build_info)
        self.assertRaises(registry.ActionError, rd.Run)

        # Multiple missing arguments
        args = [['HKLM', kpath], ['HKLM']]
        rd = registry.MultiRegDel(args, build_info)
        self.assertRaises(registry.ActionError, rd.Run)
Example #5
0
  def testDel(self, rv, build_info):
    # Variable definition
    args = [ROOT, PATH, NAME]

    # Mock delete registry keys
    rd = registry.RegDel(args, build_info)
    rd.Run()
    rv.assert_called_with(NAME, ROOT, PATH, USE_64)

    # Registry error
    rv.side_effect = registry.registry.Error
    self.assertRaises(registry.ActionError, rd.Run)
Example #6
0
    def testDel(self, warn, winreg, build_info):
        # Variable definition
        registry.WindowsError = Exception

        # Mock delete registry keys
        kpath = (r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
                 r'\SoftwareProtectionPlatform')
        args = ['HKLM', kpath, 'KeyManagementServiceName']
        rkv = winreg.return_value.RemoveKeyValue
        rd = registry.RegDel(args, build_info)

        # Registry error
        rkv.side_effect = registry.registry.RegistryError('Test')
        self.assertRaises(registry.ActionError, rd.Run)

        # Key not found
        err = registry.registry.RegistryError('Test', errno=2)
        rkv.side_effect = err
        rd.Run()
        warn.assert_called_with('Registry key %s not found', args)