![Dan Helfman](/assets/img/avatar_default.png)
* model.Note has a deleted_from member to indicate the notebook id it was deleted from (if any) * controller.Notebooks sets the deleted_from member and makes all deleted notes startup notes in the trash * new controller.Notebooks.undelete_note() method * split up the idea of UI messages into errors and informational messages, with separate CSS * updated Editor and Wiki UI code to deal with new deleted_from variable * added "undelete" button when viewing a deleted note, and "delete" changes to "delete forever" * added a "trash" link to the notebook links * reorganized responsibilities for displaying notebook/user links among Wiki.populate() and Wiki.display_user() * when deleting messages in a notebook with a trash, displaying "The note has been moved to the trash"... with a working undo button! * tweaked focusing logic in display_search_results(), which has been renamed to display_loaded_notes()
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
from model.Note import Note
|
|
|
|
|
|
class Test_note( object ):
|
|
def setUp( self ):
|
|
self.object_id = u"17"
|
|
self.title = u"title goes here"
|
|
self.contents = u"<h3>%s</h3>blah" % self.title
|
|
|
|
self.note = Note( self.object_id, self.contents )
|
|
|
|
def test_create( self ):
|
|
assert self.note.object_id == self.object_id
|
|
assert self.note.contents == self.contents
|
|
assert self.note.title == self.title
|
|
assert self.note.deleted_from == None
|
|
|
|
def test_set_contents( self ):
|
|
new_title = u"new title"
|
|
new_contents = u"<h3>%s</h3>new blah" % new_title
|
|
previous_revision = self.note.revision
|
|
|
|
self.note.contents = new_contents
|
|
|
|
assert self.note.contents == new_contents
|
|
assert self.note.title == new_title
|
|
assert self.note.deleted_from == None
|
|
assert self.note.revision > previous_revision
|
|
|
|
def test_set_contents_with_html_title( self ):
|
|
new_title = u"new title"
|
|
new_contents = u"<h3>%s<br/></h3>new blah" % new_title
|
|
previous_revision = self.note.revision
|
|
|
|
self.note.contents = new_contents
|
|
|
|
assert self.note.contents == new_contents
|
|
assert self.note.title == new_title
|
|
assert self.note.deleted_from == None
|
|
assert self.note.revision > previous_revision
|
|
|
|
def test_delete( self ):
|
|
previous_revision = self.note.revision
|
|
self.note.deleted_from = u"55"
|
|
|
|
assert self.note.deleted_from == u"55"
|
|
assert self.note.revision > previous_revision
|
|
|
|
def test_undelete( self ):
|
|
previous_revision = self.note.revision
|
|
self.note.deleted_from = None
|
|
|
|
assert self.note.deleted_from == None
|
|
assert self.note.revision > previous_revision
|
|
|
|
def test_to_dict( self ):
|
|
d = self.note.to_dict()
|
|
|
|
assert d.get( "contents" ) == self.contents
|
|
assert d.get( "title" ) == self.title
|
|
assert d.get( "deleted_from" ) == None
|