Ejemplo n.º 1
0
 def testOpenSubKeyFail(self):
     registry.WindowsError = Exception
     err = registry.RegistryError('Test', errno=2)
     self.winreg.CreateKeyEx.side_effect = err
     self.assertRaises(registry.RegistryError,
                       self.reg._OpenSubKey,
                       r'SOFTWARE\Test',
                       create=True)
Ejemplo n.º 2
0
 def test_get_active_time_no_end(self, load, utc, reg):
     start = datetime.datetime(2019, 10, 20, 19, 18, 12, 0)
     now = datetime.datetime(2019, 11, 6, 10, 45, 12, 0)
     utc.return_value = now
     reg.return_value.GetKeyValue.side_effect = registry.RegistryError(
         'Test')
     load.side_effect = (start, None)
     self.assertEqual(stage.get_active_time(6),
                      datetime.timedelta(days=16, hours=15, minutes=27))
Ejemplo n.º 3
0
 def test_get_active_time_with_end(self, load, reg):
     reg.return_value.GetKeyValue.side_effect = registry.RegistryError(
         'Test')
     load.side_effect = (datetime.datetime(2019, 11, 6, 17, 38, 52, 0),
                         datetime.datetime(2019, 11, 6, 19, 18, 52, 0))
     self.assertEqual(stage.get_active_time(3),
                      datetime.timedelta(hours=1, minutes=40))
     load.assert_has_calls([
         mock.call(reg.return_value, 3, 'Start'),
         mock.call(reg.return_value, 3, 'End')
     ])
Ejemplo n.º 4
0
 def test_get_active_time_no_start(self, load, reg):
     reg.return_value.GetKeyValue.side_effect = registry.RegistryError(
         'Test')
     load.side_effect = (None, datetime.datetime(2019, 11, 6, 19, 18, 52,
                                                 0))
     self.assertRaises(stage.Error, stage.get_active_time, 4)
Ejemplo n.º 5
0
 def test_get_active_stage_none(self, reg):
     reg.return_value.GetKeyValue.side_effect = registry.RegistryError(
         'Test')
     self.assertEqual(stage.get_active_stage(), None)
Ejemplo n.º 6
0
 def test_exit_stage_invalid(self, reg):
     reg.return_value.SetKeyValue.side_effect = registry.RegistryError(
         'Test')
     self.assertRaises(stage.Error, stage.exit_stage, 3)
Ejemplo n.º 7
0
 def test_set_stage_error(self, reg, get_active):
     get_active.return_value = None
     reg.return_value.SetKeyValue.side_effect = registry.RegistryError(
         'Test')
     self.assertRaises(stage.Error, stage.set_stage, 3)
Ejemplo n.º 8
0
 def test_load_time_reg_err(self, reg):
     r = reg.return_value
     r.GetKeyValue.side_effect = registry.RegistryError('Test')
     self.assertEqual(stage._load_time(r, 1, 'End'), None)