def testCloseDoesNotTriggerAutoSave(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') self.taskFile.tasks().append(task.Task()) self.autoSaver.on_idle(dummy.Event()) self.taskFile.close() self.assertEqual(1, self.taskFile.saveCalled)
def testAddOneTaskWhenAutoSaveIsOn(self): self.settings.set('file', 'autoexport', '["Todo.txt"]') self.settings.set('file', 'autosave', 'True') autosaver = persistence.AutoSaver(self.settings) self.taskFile.tasks().append(task.Task(subject='Some task')) autosaver.on_idle(dummy.Event()) self.assertEqual('Some task\n', file(self.txtFilename, 'r').read())
def testImportOneTaskWhenAutoSaving(self): self.settings.set('file', 'autoimport', '["Todo.txt"]') self.settings.set('file', 'autosave', 'True') autosaver = persistence.AutoSaver(self.settings) with file(self.txtFilename, 'w') as todoTxtFile: todoTxtFile.write('Imported task\n') self.taskFile.tasks().append(task.Task(subject='Some task')) autosaver.on_idle(dummy.Event()) self.assertEqual(2, len(self.taskFile.tasks()))
def testLoadWithExceptionDoesNotTriggerAutoSave(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') try: self.taskFile.load(throw=True) except IOError: pass self.autoSaver.on_idle(dummy.Event()) self.failIf(self.taskFile.saveCalled)
def testSetHourlyFee(self): self.editor._interior[5]._hourlyFeeEntry.SetValue(100) self.editor._interior[5]._hourlyFeeSync.onAttributeEdited(dummy.Event()) self.assertEqual(100, self.task.hourlyFee())
def testSetNegativePriority(self): self.editor._interior[0]._priorityEntry.SetValue(-1) self.editor._interior[0]._prioritySync.onAttributeEdited(dummy.Event()) self.assertEqual(-1, self.task.priority())
def testThatPickingAFontChangesTheItemFont(self): font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) font.SetPointSize(font.GetPointSize() + 1) self.appearance._fontEntry.SetValue(font) self.appearance._fontSync.onAttributeEdited(dummy.Event()) self.assertEqual(font, self.item.font())
def testThatPickingABackgroundColorChangesTheItemBackgroundColor(self): self.appearance._backgroundColorEntry.SetValue(wx.RED) self.appearance._backgroundColorSync.onAttributeEdited(dummy.Event()) self.assertEqual(wx.RED, self.item.backgroundColor())
def testThatPickingAnIconChangesTheItemIcon(self): self.appearance._iconEntry.SetValue('bomb_icon') self.appearance._iconSync.onAttributeEdited(dummy.Event()) self.assertEqual('bomb_icon', self.item.icon())
def testThatPickingAColorChangesTheFontButtonColor(self): self.appearance._foregroundColorEntry.SetValue(wx.RED) self.appearance._foregroundColorSync.onAttributeEdited(dummy.Event()) self.assertEqual(wx.RED, self.appearance._fontEntry.GetColor())
def testLoadDoesNotTriggerAutoSave(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') self.taskFile.load() self.autoSaver.on_idle(dummy.Event()) self.failIf(self.taskFile.saveCalled)
def testChangeTask(self): self.editor._interior._taskEntry.SetValue(self.task2) self.editor._interior._taskSync.onAttributeEdited(dummy.Event()) self.assertEqual(self.task2, self.effort.task()) self.failIf(self.effort in self.task.efforts())
def setDescription(self, newDescription): page = super(TaskEditorBySettingFocusMixin, self).setDescription(newDescription) if operating_system.isGTK(): page._descriptionSync.onAttributeEdited(dummy.Event()) # pragma: no cover else: page._subjectEntry.SetFocus() # pragma: no cover
def testFileChanged_ButNoFilename(self): self.settings.set('file', 'autosave', 'True') self.taskFile.tasks().append(task.Task()) self.autoSaver.on_idle(dummy.Event()) self.failIf(self.taskFile.saveCalled)
def testFileChanged_ButAutoSaveOff(self): self.settings.set('file', 'autosave', 'False') self.taskFile.setFilename('whatever.tsk') self.taskFile.tasks().append(task.Task()) self.autoSaver.on_idle(dummy.Event()) self.failIf(self.taskFile.saveCalled)
def testFileChanged_ButNoFilenameAndAutoSaveOff(self): self.taskFile.tasks().append(task.Task()) self.autoSaver.on_idle(dummy.Event()) self.failIf(self.taskFile.saveCalled)
def testMergeDoesTriggerAutoSave(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') self.taskFile.merge('another-non-existing-file.tsk') self.autoSaver.on_idle(dummy.Event()) self.assertEqual(1, self.taskFile.saveCalled)
def testSetFixedFee(self): self.editor._interior[5]._fixedFeeEntry.SetValue(100.5) self.editor._interior[5]._fixedFeeSync.onAttributeEdited(dummy.Event()) self.assertEqual(100.5, self.task.fixedFee())
def testFileChanged(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') self.taskFile.tasks().append(task.Task()) self.autoSaver.on_idle(dummy.Event()) self.assertEqual(1, self.taskFile.saveCalled)
def testBehaviorMarkCompleted(self): page = self.editor._interior[3] page._shouldMarkCompletedEntry.SetStringSelection('Yes') page._shouldMarkCompletedSync.onAttributeEdited(dummy.Event()) self.assertEqual(True, self.task.shouldMarkCompletedWhenAllChildrenCompleted())
def testSaveAsDoesNotTriggerAutoSave(self): self.settings.set('file', 'autosave', 'True') self.taskFile.setFilename('whatever.tsk') self.taskFile.saveas('newfilename.tsk') self.autoSaver.on_idle(dummy.Event()) self.assertEqual(1, self.taskFile.saveCalled)
def testInvalidEffort(self): self.editor._interior._stopDateTimeEntry.SetValue(date.DateTime(1900, 1, 1)) self.editor._interior.onDateTimeChanged(dummy.Event()) self.failUnless(self.editor._interior._invalidPeriodMessage.GetLabel())
def testThatPickingAColoredFontChangesTheItemColor(self): self.appearance._fontEntry.SetColor(wx.RED) self.appearance._fontColorSync.onAttributeEdited(dummy.Event()) self.assertEqual(wx.RED, self.item.foregroundColor())
def testChangeTaskDoesNotCloseEditor(self): self.editor._interior._taskEntry.SetValue(self.task2) self.editor._interior._taskSync.onAttributeEdited(dummy.Event()) self.failIf(self.editor.editorClosed)
def testDontShowSameMessageTwice(self): dialog = self.checker.run(show=False) self.assertEqual('Message', dialog.current_message()) dialog.on_close(dummy.Event()) self.assertEqual(None, self.checker.run(show=False))