def test_for_mock_callback_create(self): mock_receiver = Mock(Receiver) fs = FileSystemWatcher('/foo/bar') fs.onChangeCallbacks = dict(create=mock_receiver.subscribeTarget, delete=mock_receiver.unsubscribeTarget) fs.onChange('watch', self.PATH, self.CREATE) self.assertTrue(mock_receiver.subscribeTarget.called)
def test_inotify_is_started(self, mock_inotify): fs = FileSystemWatcher('/foo/bar') fs.startService() self.assertTrue(mock_inotify.INotify().startReading.called)
def test_for_missing_callbacks(self): fs = FileSystemWatcher('/foo/bar') self.assertRaises( AttributeError, fs.onChange, 'watch', self.PATH, self.CREATE)