def testLogCopyValidate(self): log_host = 'log-server.example.com' lc = installer.LogCopy(r'X:\glazier.log', None) self.assertRaises(installer.ValidationError, lc.Validate) lc = installer.LogCopy([1, 2, 3], None) self.assertRaises(installer.ValidationError, lc.Validate) lc = installer.LogCopy([1], None) self.assertRaises(installer.ValidationError, lc.Validate) lc = installer.LogCopy([r'X:\glazier.log'], None) lc.Validate() lc = installer.LogCopy([r'X:\glazier.log', log_host], None) lc.Validate()
def testLogCopy(self, copy): log_file = r'X:\glazier.log' log_host = 'log-server.example.com' # copy eventlog lc = installer.LogCopy([log_file], None) lc.Run() copy.return_value.EventLogCopy.assert_called_with(log_file) self.assertFalse(copy.return_value.ShareCopy.called) copy.reset_mock() # copy both lc = installer.LogCopy([log_file, log_host], None) lc.Run() copy.return_value.EventLogCopy.assert_called_with(log_file) copy.return_value.ShareCopy.assert_called_with(log_file, log_host) copy.reset_mock() # copy errors copy.return_value.EventLogCopy.side_effect = installer.log_copy.LogCopyError copy.return_value.ShareCopy.side_effect = installer.log_copy.LogCopyError lc.Run() copy.return_value.EventLogCopy.assert_called_with(log_file) copy.return_value.ShareCopy.assert_called_with(log_file, log_host)