def testDontWriteInheritedNoteBackgroundColor(self): parent = note.Note(bgColor=wx.RED) child = note.Note(subject='child', id='id') parent.addChild(child) self.noteContainer.append(parent) self.expectInXML('<note creationDateTime="%s" id="id" status="1" ' 'subject="child" />' % child.creationDateTime())
def fillContainers(self): # pylint: disable-msg=W0201 self.description = 'Description\nLine 2' self.task = task.Task(subject='Subject', description=self.description, startDateTime=date.Now() - date.TimeDelta(days=1), dueDateTime=date.Now() + date.TimeDelta(days=1), completionDateTime=date.Now() - date.TimeDelta(days=1), budget=date.TimeDelta(hours=1), priority=4, hourlyFee=100.5, fixedFee=1000, recurrence=date.Recurrence('weekly', max=10, count=5, amount=2), reminder=date.DateTime(2004,1,1), fgColor=wx.BLUE, bgColor=wx.RED, font=wx.NORMAL_FONT, expandedContexts=['viewer1'], icon='icon', selectedIcon='selectedIcon', shouldMarkCompletedWhenAllChildrenCompleted=True, percentageComplete=67) self.child = task.Task() self.task.addChild(self.child) self.grandChild = task.Task() self.child.addChild(self.grandChild) self.task.addEffort(effort.Effort(self.task, start=date.DateTime(2004,1,1), stop=date.DateTime(2004,1,2), description=self.description)) self.category = category.Category('test', [self.task], filtered=True, description='Description', exclusiveSubcategories=True) self.categories.append(self.category) # pylint: disable-msg=E1101 self.task.addAttachments(attachment.FileAttachment('/home/frank/whatever.txt')) self.task.addNote(note.Note(subject='Task note')) self.task2 = task.Task('Task 2', priority=-1954) self.taskList.extend([self.task, self.task2]) self.note = note.Note(subject='Note', description='Description', children=[note.Note(subject='Child')]) self.notes.append(self.note) self.category.addCategorizable(self.note)
def setUp(self): super(NoteCommandTestCase, self).setUp() self.note1 = note.Note() self.note2 = note.Note() self.list = self.noteContainer = note.NoteContainer( [self.note1, self.note2]) self.original = note.NoteContainer([self.note1, self.note2])
def testTaskWithNoteWithSubNoteWithCategory(self): newNote = note.Note() newSubNote = note.Note() newNote.addChild(newSubNote) self.task.addNote(newNote) newSubNote.addCategory(self.category) self.category.addCategorizable(newSubNote) self.expectInXML('categorizables="%s"' % newSubNote.id())
def setUp(self): super(DragAndDropNoteCommand, self).setUp() self.parent = note.Note(subject='parent') self.child = note.Note(subject='child') self.grandchild = note.Note(subject='grandchild') self.parent.addChild(self.child) self.child.addChild(self.grandchild) self.notes.extend([self.parent])
def testAddNoteWithSubnote(self): parent = note.Note(subject='New note') child = note.Note(subject='Child') parent.addChild(child) child.setParent(parent) self.editor._interior[7].notes.extend([parent, child]) self.editor.ok() # Only the parent note should be added to the notes list: self.assertEqual(1, len(self.task.notes()))
def testAddNoteWithSubnote(self): parent = note.Note(subject='New note') child = note.Note(subject='Child') parent.addChild(child) child.setParent(parent) viewer = self.editor._interior[7].viewer viewer.newItemCommand(viewer.presentation()).do() viewer.newSubItemCommandClass()(list=viewer.presentation(), items=viewer.presentation()).do() # Only the parent note should be added to the notes list: self.assertEqual(1, len(self.task.notes()))
def testNeedSave_AfterRemoveNoteChild(self): child = note.Note() list(self.taskFile.notes())[0].addChild(child) self.taskFile.setFilename(self.filename) self.taskFile.save() list(self.taskFile.notes())[0].removeChild(child) self.failUnless(self.taskFile.needSave())
def testNeedSave_AfterTaskNoteChanged(self): self.taskFile.setFilename(self.filename) newNote = note.Note(subject='Note') self.task.addNote(newNote) # pylint: disable-msg=E1101 self.taskFile.save() newNote.setSubject('New subject') self.failUnless(self.taskFile.needSave())
def testNote(self): aNote = note.Note(id='id') self.noteContainer.append(aNote) self.expectInXML( '<note creationDateTime="%s" id="id" status="%d" ' '/>' % (aNote.creationDateTime(), base.SynchronizedObject.STATUS_NEW))
def __init__(self, *args, **kwargs): self.owners = [] super(AddNoteCommand, self).__init__(*args, **kwargs) self.owners = self.items self.items = self.__notes = [note.Note(subject=_('New note')) \ for dummy in self.items] self.save_modification_datetimes()
def __parse_note_node(self, note_node): ''' Parse the attributes and child notes from the noteNode. ''' kwargs = self.__parse_base_composite_attributes( note_node, self.__parse_note_nodes) if self.__tskversion > 20: kwargs['attachments'] = self.__parse_attachments(note_node) return self.__save_modification_datetime(note.Note(**kwargs)) # pylint: disable=W0142
def testObjectWithAttachmentWithNote(self): att = attachment.FileAttachment('whatever.txt', id='foo') self.task.addAttachments(att) att.addNote(note.Note(subject='attnote', id='spam')) self.expectInXML( '<attachment id="foo" location="whatever.txt" status="1" subject="whatever.txt" type="file">\n<note' )
def testLocalNoteViewerForItemWithoutNotes(self): taskFile = persistence.TaskFile() taskFile.notes().append(note.Note()) viewer = gui.viewer.NoteViewer(self.frame, taskFile, config.Settings(load=False), notesToShow=note.NoteContainer()) self.failIf(viewer.presentation())
def testPurgeNothing(self): myTask = task.Task(subject='Task') myNote = note.Note(subject='Note') self.taskFile.tasks().append(myTask) self.taskFile.notes().append(myNote) self.iocontroller.purgeDeletedItems() self.assertEqual(self.taskFile.tasks(), [myTask]) self.assertEqual(self.taskFile.notes(), [myNote])
def testCategoryWithNestedNotes(self): subNote = note.Note(subject='Subnote', id='id') self.note.addChild(subNote) self.category.addNote(self.note) self.expectInXML( '>\n<note id="%s" status="1">\n' '<note id="id" status="1" subject="Subnote"/>\n</note>\n</category>' % self.note.id())
def testTaskWithNotes(self): anotherNote = note.Note(subject='Another note', id='id') self.task.addNote(self.note) self.task.addNote(anotherNote) self.expectInXML( '>\n<note id="%s" status="1"/>\n' '<note id="id" status="1" subject="Another note"/>\n</task>' % self.note.id())
def testCategoryWithNotes(self): anotherNote = note.Note(subject='Another note', id='id') self.category.addNote(self.note) self.category.addNote(anotherNote) self.expectInXML( '>\n<note id="%s" status="1"/>\n' '<note id="id" status="1" subject="Another note"/>\n</category>' % self.note.id())
def testCopy_NoteOwnerWithNoteWithSubNote(self): child = note.Note(subject='child') self.note.addChild(child) self.noteOwner.addNote(self.note) copy = NoteOwnerUnderTest(**self.noteOwner.__getcopystate__()) childCopy = copy.notes()[0].children()[0] self.assertNotEqual(childCopy.id(), child.id()) self.assertEqual(childCopy.subject(), child.subject())
def testObjectWithAttachmentWithNote(self): att = attachment.FileAttachment('whatever.txt', id='foo') self.task.addAttachments(att) attachment_note = note.Note(subject='attnote', id='spam') att.addNote(attachment_note) self.expectInXML('<attachment creationDateTime="%s" id="foo" ' 'location="whatever.txt" ' 'status="1" subject="whatever.txt" type="file">\n' '<note' % att.creationDateTime())
def __init__(self, *args, **kwargs): subject = kwargs.pop('subject', _('New note')) description = kwargs.pop('description', '') attachments = kwargs.pop('attachments', []) categories = kwargs.get('categories', None) super(NewNoteCommand, self).__init__(*args, **kwargs) self.items = self.notes = [note.Note(subject=subject, description=description, categories=categories, attachments=attachments)]
def testNoteWithChild(self): child = note.Note(id='child') self.note.addChild(child) self.noteContainer.append(child) self.expectInXML('<note id="%s" status="%d">\n' '<note id="child" status="%d"/>\n' '</note>' % (self.note.id(), base.SynchronizedObject.STATUS_NEW, base.SynchronizedObject.STATUS_NEW))
def testTaskWithNotes(self): anotherNote = note.Note(subject='Another note', id='id') self.task.addNote(self.note) self.task.addNote(anotherNote) self.expectInXML( '>\n<note creationDateTime="%s" id="%s" status="1" />\n' '<note creationDateTime="%s" id="id" status="1" subject="Another note" ' '/>\n</task>' % (self.note.creationDateTime(), self.note.id(), anotherNote.creationDateTime()))
def setUp(self): super(NoteViewerTest, self).setUp() self.settings = config.Settings(load=False) self.taskFile = persistence.TaskFile() self.note = note.Note() self.taskFile.notes().append(self.note) self.viewer = gui.viewer.NoteViewer(self.frame, self.taskFile, self.settings, notesToShow=self.taskFile.notes())
def testCategoryWithNotes(self): anotherNote = note.Note(subject='Another note', id='id') self.category.addNote(self.note) self.category.addNote(anotherNote) self.expectInXML( '>\n<note creationDateTime="%s" id="%s" status="1" />\n' '<note creationDateTime="%s" id="id" status="1" subject="Another ' 'note" />\n</category>' % (self.note.creationDateTime(), self.note.id(), anotherNote.creationDateTime()))
def setUp(self): super(EditorTestCase, self).setUp() self.settings = config.Settings(load=False) self.taskFile = persistence.TaskFile() self.items = base.filter.SearchFilter(self.taskFile.notes()) self.item = note.Note(subject='item') self.items.append(self.item) self.editor = EditorUnderTest(self.frame, [self.item], self.settings, self.items, self.taskFile) self.appearance = self.editor._interior[-1]
def testTaskWithNestedNotes(self): subNote = note.Note(subject='Subnote', id='id') self.note.addChild(subNote) self.task.addNote(self.note) self.expectInXML( '>\n<note creationDateTime="%s" id="%s" status="1">\n' '<note creationDateTime="%s" id="id" status="1" subject="Subnote" ' '/>\n</note>\n</task>' % (self.note.creationDateTime(), self.note.id(), subNote.creationDateTime()))
def __init__(self, *args, **kwargs): self.__owner = kwargs.pop('owner') self.__parents = [] super(AddSubNoteCommand, self).__init__(*args, **kwargs) self.__parents = self.items self.__notes = kwargs.get('notes', [note.Note(subject=_('New subnote'), parent=parent) \ for parent in self.__parents]) self.items = self.__notes self.save_modification_datetimes()
def testSaveTaskFileWithoutTasksButWithNotes(self): self.taskFile.notes().append(note.Note(subject='Note')) def saveasReplacement(*args, **kwargs): # pylint: disable=W0613 self.saveAsCalled = True # pylint: disable=W0201 originalSaveAs = self.iocontroller.__class__.saveas self.iocontroller.__class__.saveas = saveasReplacement self.iocontroller.save() self.failUnless(self.saveAsCalled) self.iocontroller.__class__.saveas = originalSaveAs
def setUp(self): task.Task.settings = config.Settings(load=False) self.fd = StringIO.StringIO() self.fd.name = 'testfile.tsk' self.writer = persistence.XMLWriter(self.fd) self.task = task.Task() self.taskList = task.TaskList([self.task]) self.category = category.Category('Category') self.categoryContainer = category.CategoryList([self.category]) self.note = note.Note() self.noteContainer = note.NoteContainer([self.note])