Example #1
0
    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))
Example #2
0
    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))
Example #3
0
    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')
Example #4
0
    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)
Example #5
0
 def test_plaintext_markdown(self):
     note = Note(_path('my note.md'))
     self.assertEqual(note.plaintext, 'HEY HI\nfoo bar qua')
Example #6
0
 def test_content_pdf(self):
     note = Note(_path('womp.pdf'))
     self.assertEqual(note.content, '[PDF]')