def test_add_note(self): note = Note(_path('new note.md')) note.write('foobar') self.index.add_note(note) self.assertEqual(self.index.size, self.expected_notes + 1)
def clip(save, edit, browser, overwrite): """convert html in the clipboard to markdown""" html = clipboard.get_clipboard_html() if html is None: click.echo('No html in the clipboard') return if save is None: content = html2md.html_to_markdown(html).strip() click.echo(content) return if not save.endswith('.md'): click.echo('Note must have extension ".md"') return note = Note(save) if os.path.exists(note.path.abs) and not overwrite: click.echo('Note already exists at "{}" (specify `--overwrite` to overwrite)'.format(note.path.abs)) return html = parsers.rewrite_external_images(html, note) content = html2md.html_to_markdown(html).strip() note.write(content) if browser: click.launch('http://localhost:{0}/{1}'.format(conf.PORT, note.path.rel)) if edit: click.edit(filename=note.path.abs)
def test_on_created(self): note = Note(_path('a new note.md')) note.write('# a new note') e = Event(is_directory=False, src_path=note.path.abs, dest_path=None) self.handler.on_created(e) self.assertTrue(self.nomadic.index.note_at(note.path.rel))
def test_update_note(self): note = Note(_path('my note.md')) note.write(u'changed note content') self.index.update_note(note) note_ = self.index.note_at(note.path.rel) self.assertTrue(note_) self.assertEqual(note_['content'], u'changed note content')
def test_on_modified(self): note = Note(_path('my note.md')) note.write('a changed note') e = Event(is_directory=False, src_path=note.path.abs, dest_path=None) self.handler.on_modified(e) note = self.nomadic.index.note_at(note.path.rel) self.assertEqual('a changed note', note['content'])