def test_mention_workspace_html_output_target_set(self, processing_options): mention = MentionNote(processing_options, 'my_contents', '1234', '5678') mention.target_path = { Path('folder1/note.md'), Path('folder2/note.md') } expected = '<a href="folder1/note.md">my_contents in folder1, </a><a href="folder2/note.md">my_contents in folder2, </a> ' assert mention.html() == expected
def test_mention_workspace_markdown_output_target_set( self, processing_options): mention = MentionNote(processing_options, 'my_contents', 'ws-1234', 'note-5678') mention.target_path = { Path('folder1/note.md'), Path('folder2/note.md') } expected = '[my_contents in folder1](folder1/note.md), [my_contents in folder2](folder2/note.md), ' mention_markdown = mention.markdown() assert mention_markdown == expected
def extract_from_mention_items(mention_tag, processing_options: NimbusProcessingOptions): mention_type = mention_tag.get('data-mention-type', None) if not mention_type: return contents = mention_tag.get('data-mention-name', '') if mention_type == 'user': return MentionUser(processing_options, contents) if mention_type == 'workspace': mention_workspace_id = mention_tag.get('data-mention-object_id', '') return MentionWorkspace(processing_options, contents, mention_workspace_id) if mention_type == 'folder': mention_workspace_id = mention_tag.get('data-mention-workspace_id', '') mention_folder_id = mention_tag.get('data-mention-object_id', '') return MentionFolder(processing_options, contents, mention_workspace_id, mention_folder_id) if mention_type == 'note': mention_workspace_id = mention_tag.get('data-mention-workspace_id', '') mention_note_id = mention_tag.get('data-mention-object_id', '') return MentionNote(processing_options, contents, mention_workspace_id, mention_note_id)
def test_set_target_paths_by_matching_ids_target_note_in_same_folder_as_this_note( self, processing_options): mention = MentionNote(processing_options, 'my_contents', 'ws-1234', 'note-5678') note_paths = NotePaths() note_paths.path_to_note_target = Path('target-path/same_note_folder') note_paths.note_target_file_name = 'my-note.md' nimbus_ids = NimbusIDs() nimbus_ids.add_note('note-5678', Path('target-path/same_note_folder/my-note.md')) mention.set_target_paths_by_matching_ids(nimbus_ids, note_paths) assert mention.target_path == {Path('my-note.md')}
def test_match_link_to_mention_text_different_folder_as_note( self, processing_options, conversion_settings): mention = MentionNote(processing_options, 'my-mention-note', 'ws-1234', 'note-5678') # Mention note is the note this link links to mention_note = NimbusNote(processing_options, contents=[], conversion_settings=conversion_settings) mention_note.title = 'my-mention-note' mention_note_paths = NotePaths() # mention_note_paths.path_to_source_workspace = Path('source/workspace') # mention_note_paths.path_to_target_folder = Path('target') mention_note_paths.path_to_source_folder = Path('source') mention_note_paths.path_to_note_target = Path( 'target/workspace/mention_note_folder') mention_note.note_paths = mention_note_paths dict_of_notes = {'my-mention-note': [mention_note]} # this is the note the mention link is in this_note_note_paths = NotePaths() this_note_note_paths.path_to_source_folder = Path('source') this_note_note_paths.path_to_target_folder = Path('target') this_note_note_paths.path_to_note_source = Path( 'source/workspace/this_note_folder') this_note_note_paths.path_to_note_target = Path( 'target/workspace/this_note_folder') nimbus_ids = NimbusIDs() mention.match_link_to_mention_text(nimbus_ids, dict_of_notes, this_note_note_paths) assert mention.target_path == { Path('../mention_note_folder/my-mention-note.md') } assert len(nimbus_ids.notes) == 1 assert len(nimbus_ids.workspaces) == 1
def test_try_to_set_target_path_when_different_folder_as_note_and_id_exists( self, processing_options): mention = MentionNote(processing_options, 'my_contents', 'ws-1234', 'note-5678') note_paths = NotePaths() note_paths.path_to_note_target = Path( 'target-path/different_note_folder') note_paths.note_target_file_name = 'different-note.md' dict_of_notes = {'a-different-note': []} nimbus_ids = NimbusIDs() nimbus_ids.add_note( 'note-5678', Path('target-path/mention_note_folder/mention-note.md')) mention.try_to_set_target_path(note_paths, nimbus_ids, dict_of_notes) assert mention.target_path == { Path('../mention_note_folder/mention-note.md') }
def test_mention_folder_html_output_target_not_set(self, processing_options): mention = MentionNote(processing_options, 'my_contents', 'ws-1234', 'note-5678') expected = '<a href="">my_contents - Unable to link to note. </a>' assert mention.html() == expected
def test_mention_note_markdown_output_target_not_set( self, processing_options): mention = MentionNote(processing_options, 'my_contents', 'ws-1234', 'note-5678') expected = '[my_contents - Unable to link to note]()' assert mention.markdown() == expected