Пример #1
0
 def testSetTimerValidate(self):
     st = timers.SetTimer('Timer1', None)
     self.assertRaises(ValidationError, st.Validate)
     st = timers.SetTimer([1, 2, 3], None)
     self.assertRaises(ValidationError, st.Validate)
     st = timers.SetTimer([1], None)
     self.assertRaises(ValidationError, st.Validate)
     st = timers.SetTimer(['Timer1'], None)
     st.Validate()
Пример #2
0
 def testSetTimerValidate(self):
   st = timers.SetTimer(VALUE_NAME, None)
   self.assertRaises(ValidationError, st.Validate)
   st = timers.SetTimer([1, 2, 3], None)
   self.assertRaises(ValidationError, st.Validate)
   st = timers.SetTimer([1], None)
   self.assertRaises(ValidationError, st.Validate)
   st = timers.SetTimer([VALUE_NAME], None)
   st.Validate()
Пример #3
0
 def testSetTimer(self, sv, build_info):
   build_info.TimerGet.return_value = VALUE_DATA
   st = timers.SetTimer([VALUE_NAME], build_info)
   st.Run()
   build_info.TimerSet.assert_called_with(VALUE_NAME)
   sv.assert_called_with('TIMER_' + VALUE_NAME, VALUE_DATA, 'HKLM',
                         KEY_PATH, log=False)
Пример #4
0
  def testSetTimer(self, winreg, build_info):
    args = ['Timer1']
    build_info.TimerGet.return_value = '2019-11-11 13:33:37.133337'
    st = timers.SetTimer(args, build_info)
    st.Run()
    build_info.TimerSet.assert_called_with('Timer1')

    # Successfully add registry keys
    args = [
        'HKLM', r'SOFTWARE\Test', 'TIMER_image_start',
        '2019-11-11 13:33:37.133337',
        'REG_SZ', False
    ]
    ra = timers.RegAdd(args, build_info)
    ra.Run()

    # Fail to add registry key
    skv = winreg.return_value.SetKeyValue
    skv.side_effect = registry.registry.RegistryError
    self.assertRaises(registry.ActionError, ra.Run)
Пример #5
0
 def testSetTimer(self, build_info):
     args = ['Timer1']
     st = timers.SetTimer(args, build_info)
     st.Run()
     build_info.TimerSet.assert_called_with('Timer1')
Пример #6
0
 def testSetTimerError(self, sv, build_info):
   build_info.TimerGet.return_value = VALUE_DATA
   sv.side_effect = timers.registry.Error
   st = timers.SetTimer([VALUE_NAME], build_info)
   self.assertRaises(timers.Error, st.Run)