Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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))
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
    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')
Ejemplo n.º 7
0
    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')
Ejemplo n.º 8
0
    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'])
Ejemplo n.º 9
0
    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'])