def dump(self): if not self._disable_dump: self._watcher.stop_observer() tmpdict = self.dump_options() logger.debug("Dump Getting Called {}".format(tmpdict)) write_data_file(tmpdict, self._file) self._watcher.start_observer()
def dump(self): # TODO signal observer to turn off and then turn on again self._watcher.stop_observer() tmpdict = self.dump_options() logger.debug("Dump Getting Called {}".format(tmpdict)) write_data_file(tmpdict, self._file) self._watcher.start_observer()
def test_update(self): self.runtimeoptions.update() self.runtimeoptions.run_now = True self.runtimeoptions.dump() tmp_data = read_json_file(self.runtimeoptions._file) runtimedict = self.runtimeoptions.dump_options() self.assertTrue(tmp_data == runtimedict, "Expecting them to be the same") tmp_data['run_now'] = False write_data_file(tmp_data, self.runtimeoptions._file) self.runtimeoptions.update() runtimedict = self.runtimeoptions.dump_options() self.assertTrue(tmp_data == runtimedict, "Expecting them to be the same")
def setUp(self): set_data_file(self.data_file) write_data_file({}, self.data_file) self.watcher = WatchFile(patterns=[self.data_file]) def nothing_important(_): pass self.watcher.event_notification = nothing_important self.observer = Observer() self.observer.schedule(self.watcher, r"D:\Sync\OneDrive\Yu-gi-oh_bot", recursive=False) self.observer.start() self.data = read_data_file() self.data['test'] = 'yes' write_data_file(self.data, self.data_file)
def test_notify_event(self): write_data_file(self.data) records = [str(last_record.get_record(x)) for x in range(0, 5)] self.assertTrue("FileModifiedEvent" in ' '.join(records), "expecting a file modification event")