def test_set_target_paths_by_matching_ids(self, processing_options): mention = MentionFolder(processing_options, 'my_contents', '1234', '5678') note_paths = NotePaths() note_paths.path_to_note_target = Path('target path/this_note_folder') nimbus_ids = NimbusIDs() nimbus_ids.add_folder('5678', Path('target path/my target path')) mention.set_target_paths_by_matching_ids(nimbus_ids, note_paths) assert mention.target_path == {Path('../my target path')}
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_try_to_set_target_path(self, processing_options): mention = MentionWorkspace(processing_options, 'my_contents', '1234') note_paths = NotePaths() nimbus_ids = NimbusIDs() nimbus_ids.add_workspace('1234', Path('my_target_path')) mention.try_to_set_target_path(note_paths, nimbus_ids) assert mention.target_path == Path('my_target_path')
def test_try_to_set_target_path_when_same_folder_as_note_is_in( self, processing_options, tmp_path): Path(tmp_path, 'source/workspace/my mention folder').mkdir(parents=True) mention = MentionFolder(processing_options, 'my mention folder', '1234', '5678') note_paths = NotePaths() note_paths.path_to_source_workspace = Path(tmp_path, 'source/workspace') note_paths.path_to_target_workspace = Path(tmp_path, 'target/workspace') note_paths.path_to_target_folder = Path(tmp_path, 'target') note_paths.path_to_source_folder = Path(tmp_path, 'source') note_paths.path_to_note_target = Path( tmp_path, 'target/workspace/my-mention-folder') nimbus_ids = NimbusIDs() nimbus_ids.add_folder( '5678', Path(tmp_path, 'target/workspace/my-mention-folder')) mention.try_to_set_target_path(note_paths, nimbus_ids) assert mention.target_path == {Path('.')}
def test_set_note_target_path(self, processing_options): note_paths = NotePaths() note_paths.path_to_note_source = Path('source_folder/my folder source') note_paths.path_to_source_folder = Path('source_folder') note_paths.path_to_target_folder = Path('target_folder') note_paths.set_note_target_path(processing_options) assert note_paths.path_to_note_target == Path('target_folder/my-folder-source')
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_match_link_to_mention_text(self, processing_options, tmp_path): Path(tmp_path, 'source/workspace/my mention folder').mkdir(parents=True) mention = MentionFolder(processing_options, 'my mention folder', '1234', '5678') note_paths = NotePaths() note_paths.path_to_source_workspace = Path(tmp_path, 'source/workspace') note_paths.path_to_target_folder = Path(tmp_path, 'target') note_paths.path_to_source_folder = Path(tmp_path, 'source') note_paths.path_to_note_target = Path( tmp_path, 'target/workspace/this_note_folder') nimbus_ids = NimbusIDs() mention.match_link_to_mention_text(nimbus_ids, note_paths) assert mention.target_path == {Path('../my-mention-folder')}