@@ -146,8 +146,11 @@ def setUp(self):
146146 texteditor .DataValidationHandler (self .plugin ))
147147 self .plugin .enable ()
148148 self .app .project .load_datafile (datafilereader .TESTCASEFILE_WITH_EVERYTHING , MessageRecordingLoadObserver ())
149+ self .notebook = self .app .book
149150 self .app .tree .set_editor (self .plugin ._editor_component )
150151 self .app .tree .populate (self .app .project )
152+ self .source = self .app .tree .controller
153+ self .plugin ._open_tree_selection_in_editor ()
151154 self .app .frame .SetStatusText ("File:" + self .app .project .data .source )
152155 # Uncomment next line (and MainLoop in tests) if you want to see the app
153156 # self.frame.Show()
@@ -421,8 +424,47 @@ def test_execute_sharp_uncomment_with_selection(self):
421424 # print(f"DEBUG: fulltext:\n{fulltext}")
422425 assert fulltext == spaces + '1 - Line one' + spaces + 'with cells' + spaces + 'last text\n '
423426 # Uncomment next lines if you want to see the app
424- wx .CallLater (5000 , self .app .ExitMainLoop )
425- self .app .MainLoop ()
427+ # wx.CallLater(5000, self.app.ExitMainLoop)
428+ # self.app.MainLoop()
429+
430+ def test_check_variables_section (self ):
431+ pos = len ('1 - Line one\n ' )
432+ spaces = ' ' * self .plugin ._editor_component .tab_size
433+ text = "${ARG} value" # Text to find (last item in Variable section)
434+ with open (datafilereader .TESTCASEFILE_WITH_EVERYTHING , "r" ) as fp : #, MessageRecordingLoadObserver())
435+ content = fp .readlines ()
436+ content = "" .join (content )
437+ # self.plugin.on_open(None)
438+ # datafilecontroller = self.app.tree.get_selected_datafile_controller()
439+ # print(f"DEBUG: datafilecontroller={datafilecontroller} controller={self.app.tree.controller}")
440+ # self.plugin._open_data_for_controller(self.app.tree.get_selected_datafile_controller())
441+ # self.plugin.on_open(wx.EVT_FILECTRL_SELECTIONCHANGED)
442+ # content = ['1 - Line one\n', '2 - Line two\n', '3 - Line three\n']
443+ # self.plugin._editor_component.source_editor.set_text(
444+ # content[0] + 'Comment' + spaces + content[1] + content[2])
445+ self .plugin ._editor_component .source_editor .set_text (content )
446+ # self.plugin._editor_component.source_editor.SetSelection(pos + 1, pos + 4)
447+ # self.plugin._editor_component.execute_uncomment(None)
448+ self .plugin ._editor_component .store_position (True )
449+ self .plugin ._editor_component .set_editor_caret_position ()
450+ position = self .plugin ._editor_component ._find_text_position (True , text )
451+ self .plugin ._editor_component ._show_search_results (position , text )
452+ position = self .plugin ._editor_component .source_editor .GetCurrentPos ()
453+ self .plugin ._editor_component .source_editor .InsertText (position , "123\n \n " )
454+ fulltext = self .plugin ._editor_component .source_editor .GetText ()
455+ # print(f"DEBUG: fulltext:\n{fulltext}")
456+ # Activate Apply to cleanup text
457+ self .plugin ._editor_component ._dirty = True
458+ # self.plugin._apply_txt_changes_to_model()
459+ # DEBUG: THIS IS THE TEST, IT FAILS BECAUSE WE DON'T HAVE data and controller
460+ # result = self.plugin._editor_component.save()
461+ # print(f"DEBUG: result={result} is_dirty={self.plugin._editor_component.dirty}")
462+ after_apply = self .plugin ._editor_component .source_editor .GetText ()
463+ print (f"DEBUG: after_apply len={ len (after_apply )} initial content len={ len (content )} :\n { after_apply } " )
464+ # assert fulltext == content[0] + content[1] + content[2]
465+ # Uncomment next lines if you want to see the app
466+ # wx.CallLater(5000, self.app.ExitMainLoop)
467+ # self.app.MainLoop()
426468
427469
428470if __name__ == '__main__' :
0 commit comments