Пример #1
0
    def test_note_search_with_title_alias(self):
        test_query = generate_random_word(30)
        # Create note that should be found
        note_id = commands.new(
            "test_pyjoplin test_note_search_with_title_alias %s" % test_query,
            "test",
            body="foo body",
        )
        self.testnote_ids.append(note_id)

        # Create note that should NOT be found
        note_id = commands.new(
            "test_pyjoplin test_note_search_with_title_alias bar",
            "test",
            body="foo body %s" % test_query,
        )
        self.testnote_ids.append(note_id)

        # Check alias filter 't:' works (finding only 1st note)
        search_str = "t: %s" % test_query
        found_index_notes = commands.search(search_str)
        self.assertEqual(len(found_index_notes), 1)

        # Check alias filter 's:' works (finding only 2nd note)
        search_str = "b: %s" % test_query
        found_index_notes = commands.search(search_str)
        self.assertEqual(len(found_index_notes), 1)
Пример #2
0
    def test_new_and_deleted_note_in_remote_dropbox(self):
        test_body = 'foo body'
        testnote_id = commands.new('test dropbox API delete',
                                   'test',
                                   body=test_body)

        # Sync Joplin with remote Dropbox to upload new test note
        subprocess.check_call('joplin sync', shell=True)

        # Check new note is in remote Dropbox
        entries = list_all_files(dbx)
        testnote_name = u"%s.md" % testnote_id
        self.assertTrue(
            any(entry.name == testnote_name for entry in entries),
            msg='Test note creation was not synced in remote Dropbox')

        # Delete local note
        commands.delete(testnote_id)

        # Sync Joplin with remote Dropbox to delete test note
        subprocess.check_call('joplin sync', shell=True)

        # Check note was deleted in remote Dropbox
        entries = list_all_files(dbx)
        filter_entries = [
            entry for entry in entries if entry.name == testnote_name
        ]
        testnote_entry = next(entry for entry in entries
                              if entry.name == testnote_name)
        self.assertIsInstance(
            testnote_entry,
            dropbox.files.DeletedMetadata,
            msg='Test note deletion was not synced in remote Dropbox')
Пример #3
0
    def test_imfeelinglucky_stub_multiline(self):
        test_title = 'pyjoplin-test test_note_search_single_word'
        test_body = """
foo foo foo

# Solution: (working or not)
blablabla
```python
code
stub
```

bar bar bar
"""

        note_id = commands.new(test_title, 'test', body=test_body)
        self.testnote_ids.append(note_id)

        stub = commands.imfeelinglucky(note_id)
        self.assertEqual(stub, 'code\nstub')

        # Check clipboard was correctly populated
        import pyperclip
        clipboard_content = pyperclip.paste()
        self.assertEqual(stub, clipboard_content)
Пример #4
0
    def test_edit_note_with_body(self):
        test_title = "foo test"
        test_body = "foo body"
        # HACK: Find existing to robustify against previous non-cleaned unit test
        testnote_id = commands.find_title(test_title) or commands.new(
            test_title, "test", body=test_body)

        # Edit to manually debug
        commands.edit(testnote_id)

        commands.delete(testnote_id)
Пример #5
0
    def test_note_search_single_word(self):
        test_title = "pyjoplin-test test_note_search_single_word"
        test_query = generate_random_word(30)
        test_body = (u"""
            This is a %s word
            """ % test_query)

        note_id = commands.new(test_title, "test", body=test_body)
        self.testnote_ids.append(note_id)

        # Check fulltext search works
        found_index_notes = commands.search(test_query)
        self.assertEqual(len(found_index_notes), 1)
Пример #6
0
    def test_note_to_file_with_unicode(self):
        test_title = 'pyjoplin_test test_note_to_file_with_unicode'
        test_body = u"This is a unicode string: \u2192"

        note_id = commands.new(test_title, 'test', body=test_body)
        new_note = Note.get(Note.id == note_id)

        path_tempfile = '/tmp/pyjoplin/test_note_to_file_with_unicode'
        new_note.to_file(path_tempfile)

        backup_body = new_note.body
        new_note.from_file(path_tempfile)

        self.assertEqual(new_note.body, backup_body)