def test_clean_note_assets(self): note = Note(_path('my note.md')) note_asset = _path('assets/my note/foo.jpg') self.assertTrue(exists(note_asset)) note.clean_assets(delete=True) self.assertFalse(exists(note_asset))
def test_delete_note(self): src = _path('my note.md') src_asset = _path('assets/my note/foo.jpg') self.assertTrue(exists(src)) self.assertTrue(exists(src_asset)) note = Note(src) note.delete() self.assertFalse(exists(src)) self.assertFalse(exists(src_asset))
def test_move_note(self): src = _path('my note.md') dest = _path('some_notebook/my moved note.md') src_asset = _path('assets/my note/foo.jpg') dest_asset = _path('some_notebook/assets/my moved note/foo.jpg') note = Note(src) note.move(dest) self.assertTrue(exists(dest)) self.assertTrue(exists(dest_asset)) self.assertFalse(exists(src)) self.assertFalse(exists(src_asset)) self.assertEquals(note.path.abs, dest) self.assertEquals(note.title, 'my moved note')
def test_update_references_markdown(self): path = _path('some_notebook/a cool note.md') ref = _path('some_notebook/nested book/empty.md') ref_new = _path('moved empty note.md') rel_link = 'nested book/empty.md' rel_link_new = '../moved empty note.md' with open(path, 'r') as note: note_content = note.read() self.assertTrue(rel_link in note_content) self.assertFalse(rel_link_new in note_content) self.handler.update_references(ref, ref_new) with open(path, 'r') as note: note_content = note.read() self.assertFalse(rel_link in note_content) self.assertTrue(rel_link_new in note_content)
def test_plaintext_markdown(self): note = Note(_path('my note.md')) self.assertEqual(note.plaintext, 'HEY HI\nfoo bar qua')
def test_content_pdf(self): note = Note(_path('womp.pdf')) self.assertEqual(note.content, '[PDF]')